Email or username:

Password:

Forgot your password?
Axel Rauschmayer

Node.js v22.7.0: If you write a script in ESM format, you previously had two choices:
– Use the filename extension .mjs
– Use the filename extension .js and a package.json with "type":"module"

There is now a third option:
– Use the filename extension .js. If there is no package.json with "type", Node.js assumes CommonJS, but transparently switches to ESM if it encounters ESM syntax (`import`, `export`, etc.).

Also works for filenames without extensions.

nodejs.org/en/blog/release/v22

#NodeJS

1 comment
Go Up