TS2307 Node.js Origin: Application & API Last updated 15 Oct 2026

TS2307: Cannot find module 'x' or its corresponding type declarations.

TypeScript can’t resolve the import — the package isn’t installed, the path alias isn’t configured, or there are no types.

Exact message you may see or its corresponding type declarations
Seen on: Node.js

Meaning

TS resolves modules using tsconfig (moduleResolution, baseUrl, paths). Path aliases (@/components) need both tsconfig paths and bundler config. Non-code imports (.css, .svg) need declarations.

Common causes

  • Package not installed
  • Path alias missing in tsconfig
  • Importing .css/.svg without a declaration
  • moduleResolution mismatch (node16/bundler)

⚡ Quick fix

  1. npm install the package (and @types/x if needed)
  2. Configure "paths" in tsconfig and the bundler
  3. Add declare module '*.svg' in a .d.ts

Detailed fix by platform

Node.js

  1. javascript
    // global.d.ts
    declare module '*.svg' { const src: string; export default src; }

How to diagnose

  1. Import — Package, alias or asset?
  2. Config — tsconfig paths/moduleResolution

🔧 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):

ERR_UNKNOWN_FILE_EXTENSION — TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" (Node.js)ERR_UNKNOWN_FILE_EXTE…MODULE_NOT_FOUND — Error: Cannot find module 'x' (MODULE_NOT_FOUND) (Node.js)MODULE_NOT_FOUNDTS2304 — TS2304: Cannot find name 'x'. (Node.js)TS2304TS2339 — TS2339: Property 'x' does not exist on type 'Y'. (Node.js)TS2339TS2345 — TS2345: Argument of type 'string | undefined' is not assignable to parameter of type 'string'. (Node.js)TS2345TS2532 / TS18048 — TS18048: 'x' is possibly 'undefined'. (TS2532: Object is possibly 'undefined'.) (Node.js)TS2532 / TS18048TS7016 — TS7016: Could not find a declaration file for module 'x'. 'x.js' implicitly has an 'any' type. (Node.js)TS7016Vite failed to resolve import — [vite] Internal server error: Failed to resolve import "x" from "src/App.jsx". Does the file exist? (React)Vite failed to resolv…TS2307

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.