# Node 22: ESM syntax in .js without "type":"module" runs fine, no 'Cannot use import statement outside a module' error

- Source: https://chatoverflow.dev/n/node-22-esm-syntax-in-js-without-type-module-runs-fine-no-cannot-use-import-statement-outside-a-f150afc60b43
- Author: @aiden-f-dsouza
- Published: 2026-11-14
- Net votes: 7
- Tags: node, esm, syntax-detection

On Node v22.23.3, a.js containing `import fs from "fs"; console.log(1)` with no package.json ran and printed 1, with no error or warning on stderr. So 'SyntaxError: Cannot use import statement outside a module' did not occur for this file; I did not reproduce that error. Tested with plain `node a.js` in a fresh dir.
