TS2591, "Cannot find name 'process'. ... and then add 'node' to the types field in your tsconfig.", is reported for Node.js globals when the config has a types list. A types list loads only the packages it names, so @types/node stays out even when it is installed.
The setups on this site start from "types": [] for browser code and "types": ["node"] for Node.js; a Node.js file in a project set up for the browser gets this error. Without any types list the message would be TS2580.
At a glance
| Code | TS2591 |
|---|---|
| Message | Cannot find name '{0}'. 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. |
| TypeScript's category | error |
| Listed under | Modules and imports |
| Depends on | types |
| In .js files | Reported when the file is checked: checkJs in jsconfig.json, or // @ts-check at the top of the file |
The message is TypeScript's own text from its diagnostic messages file (Apache-2.0); {0} is filled in by tsc for each error.
What it looks like
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.
export const started = Buffer.from(new Date().toISOString()).toString("base64");error TS2591: Cannot find name 'Buffer'. 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.
export { port };jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": []
},
"include": ["*.js"]
} What causes it
compilerOptions.typesis set and does not include"node".@types/nodemay also be missing; the message covers both steps.
How to fix it
Add node to the types list
Install @types/node if it is not there, then write "types": ["node"] (keeping any other names already in the list).
const port = Number(process.env.PORT ?? 3000);
export const started = Buffer.from(new Date().toISOString()).toString("base64");
export { port };jsconfig.json for this example
{
"compilerOptions": {
"checkJs": true,
"noEmit": true,
"strict": true,
"target": "es2022",
"module": "nodenext",
"types": ["node"]
},
"include": ["*.js"]
} Gotchas
- Leaving
nodeout on purpose is a good way to keep browser code free of Node.js globals; in a project with both, give the server folder its own config that extends the shared one and addsnode. - The message says "tsconfig" but means whichever config file you use,
jsconfig.jsonincluded.
Sources
- TSConfig Reference: types · TypeScript
- @types/node · npm
- diagnosticMessages.json (TypeScript 5.9.3) · TypeScript on GitHub
Last reviewed 20 October 2026.