sindresorhus / file-type

Detect the file type of a file, stream, or data
MIT License
3.64k stars 345 forks source link

`SyntaxError: Cannot use import statement outside a module` When running in Jest #623

Closed EricHasegawa closed 7 months ago

EricHasegawa commented 7 months ago

I'm using file-type ^19.0.0, I have a line in my file import { fileTypeFromBuffer } from 'file-type' that causes this error when I run jest over this file. ` ({"Object.":function(module,exports,require,dirname,filename,jest){import * as strtok3 from 'strtok3'; ^^^^^^

SyntaxError: Cannot use import statement outside a module`

Here's an identical issue on Stack Overflow from a year ago https://stackoverflow.com/questions/74917081/jest-error-while-trying-to-use-with-the-file-type-module-how-can-i-fix-cannot

sindresorhus commented 7 months ago

This is a problem with your Jest config, not this package.