NodeNext
A module and moduleResolution setting that makes TypeScript follow exactly the module rules of current Node.js.
In more detail
It honours package.json exports and imports fields and requires explicit file extensions in relative imports, such as ./user.js. This prevents code that type-checks but fails to load at run time. Use it for code run directly by Node.js; use bundler resolution for code built by a bundler.
Example
"module": "NodeNext", "moduleResolution": "NodeNext"Related terms
- module resolution — How a runtime or tool turns the name in an import, such as ./util.js or express, into the exact file to load.
- module (compiler option) — The compiler option that says which module system the output uses and, with NodeNext, how each file is treated.
- package.json exports — The package.json fields that declare which files a package makes importable (exports) and which private shortcuts start with # (imports).
- file extension — The part of a file name after the last dot, such as .py or .txt, that tells programs what kind of file it is.
Taught in
- tsconfig.json: target, lib, strict And NodeNext — Production TypeScript
- Verify Your Environment: Running tsc And Bun TypeScript — Production TypeScript