Skip to content

node

npm version License: MIT Node.js TypeScript

> TypeScript configuration for Node.js and CLI projects. Extends @jmlweb/tsconfig-base without DOM types.

  • ๐Ÿ”’ Strict Mode: inherits every strict flag from the base config
  • ๐ŸŸข Node.js Focused: lib: ["ES2022"], no DOM types
  • ๐Ÿš€ NodeNext Modules: Node.js ESM/CJS resolution, inherited from base
  • ๐ŸŽฏ Flexible: no file patterns imposed
Terminal window
npm install --save-dev @jmlweb/tsconfig-node @jmlweb/tsconfig-base typescript
{
"extends": "@jmlweb/tsconfig-node",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
{
"extends": "@jmlweb/tsconfig-node",
"compilerOptions": {
"outDir": "./dist",
"rootDir": "./src"
},
"include": ["src/**/*"]
}
{
"extends": "@jmlweb/tsconfig-node",
"compilerOptions": {
"noEmit": true,
"module": "ESNext",
"moduleResolution": "bundler"
},
"include": ["src/**/*"]
}

Extends @jmlweb/tsconfig-base and adds:

Option Value Description
lib ["ES2022"] ES2022 APIs only, no DOM types

All other options (strict, target: ES2022, module/moduleResolution: NodeNext, verbatimModuleSyntax, โ€ฆ) come from the base config. With NodeNext, relative imports need .js extensions.

  • โœ… Node.js applications, APIs and services
  • โœ… CLI tools and scripts
  • โœ… Server-side libraries

Browser or React code: use @jmlweb/tsconfig-react. Need DOM types in Node.js (for example fetch typings): add "lib": ["ES2022", "DOM"].

{
"extends": "@jmlweb/tsconfig-node",
"compilerOptions": {
"lib": ["ES2023"],
"types": ["node"]
}
}
{
"scripts": {
"build": "tsc",
"typecheck": "tsc --noEmit"
}
}
Terminal window
npm run typecheck
  • Node.js >= 22.12.0
  • TypeScript >= 5.0.0
  • @jmlweb/tsconfig-base (^2.0.0)
  • typescript (>=5.0.0)

Breaking: Node.js >=22.12.0 is now required (Node.js 18 and 20 are end-of-life).

  1. Upgrade Node.js to 22.12.0 or later.
  2. Update the package: npm install --save-dev @jmlweb/tsconfig-node@^2.0.0.

The compilerOptions are unchanged. See the Changelog.

MIT