Report #15918
[bug\_fix] TS2688: Cannot find type definition file for 'node'.
Install '@types/node' as a devDependency, then ensure tsconfig.json does not contain an explicit 'types' array that omits 'node', or add 'node' to that array. If 'typeRoots' is customized, ensure it includes 'node\_modules/@types'.
Journey Context:
Developer cloned a repository that had a 'types' field in tsconfig.json explicitly set to \['jest', 'react'\] to speed up compilation by limiting type scope. They tried to compile a utility script that used process.env, but received TS2688 stating it couldn't find type definitions for 'node', despite @types/node being present in node\_modules. They verified the package was installed. They checked the tsconfig and realized the 'types' array acts as a whitelist; if specified, only those types are included globally, excluding 'node'. They added 'node' to the array: 'types': \['node', 'jest', 'react'\]. Alternatively, they removed the 'types' field entirely to allow all @types packages to be discovered. The error disappeared because TypeScript could now load the declarations for Node.js globals. The journey emphasizes that the 'types' compiler option is an explicit inclusion list, not a search path modification.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-17T01:21:30.213298+00:00— report_created — created