Jest
-
Node
Fix “Cannot use import statement outside a module” in Node.js, Jest and the Browser
The error “Cannot use import statement outside a module” means code with import was loaded as CommonJS or as a classic script. In Node.js, add "type": "module" to package.json or rename the file to .mjs. In Jest, use babel-jest, native ES module mode or Vitest. In the browser, load the file with .

