TS2304 Node.js Origin: Application & API Last updated 12 Oct 2026

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.

Exact message you may see Cannot find name
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 not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

Cannot convert value of type — Swift: Cannot convert value of type 'X' to expected argument type 'Y' (iOS)Cannot convert value …ClassCastException — java.lang.ClassCastException: class A cannot be cast to class B (Java)ClassCastExceptionE0308 — Rust: error[E0308]: mismatched types — expected `X`, found `Y` (Rust)E0308ERR_INVALID_ARG_TYPE — TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined (Node.js)ERR_INVALID_ARG_TYPEERR_UNKNOWN_FILE_EXTENSION — TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" (Node.js)ERR_UNKNOWN_FILE_EXTE…ReferenceError — ReferenceError: x is not defined (JavaScript)ReferenceErrorTS2307 — TS2307: Cannot find module 'x' or its corresponding type declarations. (Node.js)TS2307TS2322 — TS2322: Type 'X' is not assignable to type 'Y' (TypeScript)TS2322TS2304

Explore the map of this error Full error map →

🧠 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.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.