Runtime - Node
Add the Node ESM module resolution and ESNext lib that code running on Node.js needs, layered on top of the Nova baseline and strict presets.
Why Use This Preset?
- Pairs
moduleandmoduleResolutionasNodeNextso imports resolve the same way TypeScript and Node do at runtime. - Loads the
ESNextlib alone, with no DOM globals, so browser-only APIs stay out of server code. - Uses Node's current module detection so emitted ESM and CommonJS match how Node treats each file.
- Drops in as the environment layer after the essentials and strict presets so you only declare where the code runs.
Usage
Add the preset after the essentials, strict, and source-role layers.
tsconfig.json
{
"extends": [
"@cbnventures/nova/presets/tsconfig/dx-essentials.json",
"@cbnventures/nova/presets/tsconfig/dx-strict.json",
"@cbnventures/nova/presets/tsconfig/role-source.json",
"@cbnventures/nova/presets/tsconfig/runtime-node.json"
]
}
What This Preset Configures
The preset sets the following compilerOptions, overriding the matching values from the layers below it.
| Setting | Value | Description |
|---|---|---|
lib | ESNext | Loads the latest built-in JavaScript types with no DOM globals. |
module | NodeNext | Emits modules using Node's current ESM and CommonJS detection. |
moduleResolution | NodeNext | Resolves imports the way Node does, matched to the module setting. |
info
The lib array replaces the parent value rather than merging with it, so this preset restates ESNext even though the baseline already sets it.
Related
- Review the layering order in TSConfig Best Practices.
- See how presets compose end to end in the Presets Overview.
- Pair it with the matching Runtime - Node ESLint preset.