[TypeScript] Fix 'Cannot find name console' for console.log

Created on November 29, 2026

TypeScript can report the following error when it checks a call to console.log() without type declarations for console.

error TS2584: Cannot find name 'console'. Do you need to change your target library? Try changing the 'lib' compiler option to include 'dom'.

For a Node.js project, install the Node.js type declarations in the project.

npm install --save-dev @types/node

If tsconfig.json lists the allowed type packages under compilerOptions.types, include "node" in that list.

For a browser project that explicitly sets compilerOptions.lib, include "DOM" alongside the existing libraries.

TypeScript