Common causes
- Forgot to import the variable, type, or function from another file
- A typo in the name — TypeScript is case-sensitive
- Using a browser global (window, document) without the dom lib in tsconfig.json
- Using a type from a library that needs its @types package installed
How to fix it
- Import the missing name: import { MyClass } from './myModule'
- Declare it if it's a local variable you forgot: const myVar = ...
- Add the appropriate lib to tsconfig.json: "lib": ["dom", "es2020"] for browser globals
- Install the @types package: npm install --save-dev @types/node for Node.js globals like process
Example
console.log(userName);
// error TS2304: Cannot find name 'userName'.Referencing a variable that hasn't been declared or imported in the current scope
Browse more errors
The Developer Hub covers 150+ errors across Git, npm, Node.js, Python, TypeScript, and Docker — with plain-English explanations and fix steps.
