TS2304 🟩 Node.js

TS2304: Cannot find name 'x'.

TypeScript doesn’t know an identifier — a missing import, missing type definitions (e.g. for Node or Jest globals), or a typo.

Seen on: Node.js

Meaning

Globals like process, require, describe, it need @types/node or @types/jest and the right "types"/"lib" settings.

Common causes

  • Missing import
  • @types/node or @types/jest not installed
  • tsconfig "types" array excluding them
  • DOM types missing from lib

⚡ Quick fix

  1. Import the symbol
  2. npm i -D @types/node @types/jest
  3. Add "types": ["node", "jest"] or remove a restrictive types array
  4. Add "DOM" to lib for browser globals

Detailed fix by platform

Node.js

  1. "compilerOptions": { "types": ["node", "jest"], "lib": ["ES2022", "DOM"] }

How to diagnose

  1. Name — Which identifier?
  2. Source — Global or module?

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.