jsconfig.json option

types and typeRoots

  • Default every package in node_modules/@types
  • Tested with TypeScript 5.9

Some type packages describe globals rather than modules: @types/node declares process, Buffer and the node: modules; @types/bun declares Bun. Nothing in your code imports them, so TypeScript needs to be told to load them. types is that list: "types": ["node"] loads @types/node, and process exists (without it, TS2591).

Leave types out and TypeScript 5.9 loads every package in node_modules/@types, including ones a dependency pulled in that have nothing to do with your code. TypeScript 6.0 changes the default to []. Writing the list keeps a config meaning the same thing in both, and keeps stray globals out.

At a glance

Write List the global types you use: ["node"] for Node.js, ["bun"] for Bun, [] for a browser project
On the command line --types
Type string[]
Default in TypeScript 5.9 every package in node_modules/@types
Default from TypeScript 6.0 [] (TypeScript 6.0)
TypeScript's description Specify type package names to be included without being referenced in a source file.
In the quick-start setups

The description is quoted from TypeScript's own option list (Apache-2.0); see the notices. The setup values are the checked configs on the quick-start pages.

Examples

main.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: main.js(2,28): error TS2591: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. main.js(2,28): error TS2591: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. main.js(2,28): error TS2591: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig. checked 21 October 2026
export const port = Number(process.env.PORT ?? 3000);error TS2591: Cannot find name 'process'. Do you need to install type definitions for node? Try `npm i --save-dev @types/node` and then add 'node' to the types field in your tsconfig.
types []: no Node.js globals.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": [
    "*.js"
  ]
}
main.js TypeScript 5.9.3 TypeScript 5.9.3, run 21 October 2026: No errors. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. No errors. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. No errors. checked 21 October 2026
export const port = Number(process.env.PORT ?? 3000);
types ["node"]: process is declared.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": [
      "node"
    ]
  },
  "include": [
    "*.js"
  ]
}

Imported packages are not affected

types controls only packages loaded for their globals. import express from "express" still finds @types/express with "types": []. And a package you import can bring globals of its own: @types/express loads @types/node, so in a project that imports Express, process exists even with an empty types list.

typeRoots

typeRoots changes where TypeScript looks for those packages, replacing the default of every node_modules/@types folder from the config file upward. JavaScript projects almost never need it; a folder of your own .d.ts files is simpler to add through include.

Gotchas

  • "types": ["node"] without @types/node installed is an error (TS2688). Install the version that matches the Node.js you run.

Sources

Last reviewed 20 October 2026.