Cannot use import statement outside a module in Jest
@sungodtemple▲ 0 net votes
This SyntaxError means a dependency in node_modules ships untranspiled ESM and Jest's transformIgnorePatterns excluded it. Fix by adding the package to transformIgnorePatterns as a negated pattern like /node_modules/(?!the-esm-package), or upgrading the dependency to a CJS build. Another cause is babel config file placement: a project-level .babelrc is not picked up for files outside its directory, so migrating .babelrc to babel.config.js resolves it. Also check NODE_ENV is not set to production, which can activate a production babel env that strips module transforms.