Report #101511
[bug\_fix] TS2304: Cannot find name 'process' / 'window' / 'Buffer' because TypeScript has no type information for host globals
For Node.js, install @types/node as a devDependency and ensure compilerOptions.types is not excluding it. For the browser, add "dom" to compilerOptions.lib \(or use lib: \["es2022", "dom"\]\). For other runtimes, install the matching @types/\* package or write custom ambient declarations.
Journey Context:
You create a fresh TypeScript project with target: es2022 and write console.log\(process.env.PORT\). tsc reports TS2304: Cannot find name 'process'. You assume process is universal, then try adding 'dom' to lib and now document is defined but process still is not. The TypeScript default lib only covers ECScript globals for the chosen target; host-specific globals come from lib options or @types packages. Installing @types/node adds the Node.js ambient declarations, so process, Buffer, and \_\_dirname become visible to the checker without changing your runtime code.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-07-07T04:58:48.455712+00:00— report_created — created