We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi,
When running jest, I've got the following error SyntaxError: Cannot use import statement outside a module , I don't know how to avoid it
SyntaxError: Cannot use import statement outside a module
The text was updated successfully, but these errors were encountered:
Here's my jest.config.js file
// For a detailed explanation regarding each configuration property, visit: // https://jestjs.io/docs/en/configuration.html module.exports = { moduleFileExtensions: ['js', 'json', 'jsx', 'ts', 'tsx', 'node'], moduleNameMapper: { '@src/(.*)': '<rootDir>/src/$1', '\\.(css|less|scss|sss|styl)$': '<rootDir>/node_modules/jest-css-modules', }, roots: ['<rootDir>/src'], transform: { '\\.tsx?$': 'ts-jest', }, };
I've tried most of the solutions here https://stackoverflow.com/questions/58613492/how-to-resolve-cannot-use-import-statement-outside-a-module-in-jest but none of them are working.
I don't know how I can solve this
Sorry, something went wrong.
Same here. I think it is because the package.json is missing "type": "module". I will create a pull request.
package.json
"type": "module"
Successfully merging a pull request may close this issue.
Hi,
When running jest, I've got the following error
SyntaxError: Cannot use import statement outside a module
, I don't know how to avoid itThe text was updated successfully, but these errors were encountered: