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
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.jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": [
"*.js"
]
} export const port = Number(process.env.PORT ?? 3000);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/nodeinstalled is an error (TS2688). Install the version that matches the Node.js you run.
Sources
- TSConfig Reference: types · TypeScript
- TSConfig Reference: typeRoots · TypeScript
- TypeScript 6.0 release notes · TypeScript handbook
- @types/node · npm
Last reviewed 20 October 2026.