Report #39057
[bug\_fix] TS2580: Cannot find name 'process'. Do you need to install type definitions for node? Try \`npm i --save-dev @types/node\`.
Install the Node.js type definitions package as a devDependency: \`npm install --save-dev @types/node\` \(or \`yarn add -D @types/node\`\). Root cause: TypeScript's default library only includes DOM and ES standard APIs. Node.js-specific globals \(\`process\`, \`Buffer\`, \`\_\_dirname\`\) and core modules \(\`fs\`, \`path\`\) are provided by the community-maintained \`@types/node\` package from DefinitelyTyped. Without these declarations, TypeScript treats these identifiers as unknown, resulting in TS2580 or TS2304 errors.
Journey Context:
You cloned a TypeScript API starter and run \`npm install\`. You write \`console.log\(process.env.PORT\);\` in \`src/index.ts\`. Running \`npx tsc\` gives TS2580: "Cannot find name 'process'." You check \`tsconfig.json\` and see \`"lib": \["ES2020"\]\`. You assume TypeScript knows about Node.js since it's server-side code. You try adding \`"types": \["node"\]\` to tsconfig, but it says cannot find type definitions. You search the error and find the official TypeScript handbook stating that Node types are not bundled. You run \`npm install -D @types/node\`. The error disappears immediately. You inspect \`node\_modules/@types/node\` and see \`process.d.ts\`, \`globals.d.ts\`, etc. You realize TypeScript is environment-agnostic—it doesn't assume Node or Browser by default. You also learn that if you set \`"types": \["node"\]\`, you can prevent other global types \(like Jest or React\) from leaking into the scope, which helps avoid name collisions in pure Node projects.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T20:01:59.829150+00:00— report_created — created