I had this issue with the file-type
package https://www.npmjs.com/package/file-type
In my tsconfig, I have "module": "commonjs",
in compilerOptions
.
Based on the file-type readme, I needed to import this way using load-esm.
import { loadEsm } from 'load-esm'
const fileType = await loadEsm<typeof import('file-type')>('file-type')
This will require you to first install loadEsm.
yarn add load-esm