TypeScript error

TS2591: Node.js globals with node missing from types

  • Error TS2591
  • Tested with TypeScript 5.9

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

CodeTS2591
MessageCannot 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 categoryerror
Listed underModules 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

server.js Error confirmed 5.9.3 TypeScript 5.9.3, run 21 October 2026: server.js(2,21): 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. server.js(5,24): 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. 6.0.3 TypeScript 6.0.3, run 21 October 2026: the same as 5.9.3. server.js(2,21): 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. server.js(5,24): 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. 7.0.2 TypeScript 7.0.2, run 21 October 2026: the same as 5.9.3. server.js(2,21): 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. server.js(5,24): 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. checked 21 October 2026
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 };
Node.js globals with a types list that leaves out node.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": []
  },
  "include": ["*.js"]
}

What causes it

  • compilerOptions.types is set and does not include "node".
  • @types/node may 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).

server.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
const port = Number(process.env.PORT ?? 3000);

export const started = Buffer.from(new Date().toISOString()).toString("base64");

export { port };
"node" added to the types list.
jsconfig.json for this example
{
  "compilerOptions": {
    "checkJs": true,
    "noEmit": true,
    "strict": true,
    "target": "es2022",
    "module": "nodenext",
    "types": ["node"]
  },
  "include": ["*.js"]
}

Gotchas

  • Leaving node out 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 adds node.
  • The message says "tsconfig" but means whichever config file you use, jsconfig.json included.

Sources

Last reviewed 20 October 2026.