MODULE_NOT_FOUND Node.js Origin: Application & API Last updated 14 Oct 2026

Error: Cannot find module 'x' (MODULE_NOT_FOUND)

Node can’t resolve the module path — the package isn’t installed, or a relative path/extension is wrong.

Exact message you may see Cannot find moduleModule not found: Error: Can't resolve
Seen on: Node.js Docker npm

Meaning

For package names, Node looks in node_modules up the directory tree. For relative paths it needs the exact file — and in ES modules, the file extension (./utils.js).

Common causes

  • npm install not run (fresh clone, CI, Docker)
  • Package in devDependencies but installed with --production
  • Wrong relative path or case (Linux is case-sensitive)
  • Missing .js extension in ESM imports
  • Running from a different working directory
  • Corrupted node_modules

⚡ Quick fix

  1. npm install (or npm ci)
  2. Fix relative path/case; add .js in ESM
  3. Delete node_modules and lockfile issues: rm -rf node_modules && npm ci
  4. Move runtime packages to dependencies

Detailed fix by platform

Node.js

  1. ESM: import { x } from './lib/x.js' — extension required.

Docker

  1. Copy package*.json and run npm ci in the image; don’t mount an empty host node_modules over it.

How to diagnose

  1. Name — Package or relative path?
  2. Installed — Present in node_modules?
  3. Path/case — Exact file exists with that case?
  4. CWD — Running from the project root?

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

0x8007007E — 0x8007007E: The specified module could not be found (Windows)0x8007007ECan't resolve 'fs' — Module not found: Can't resolve 'fs' (Next.js / webpack 5) (React)Can't resolve 'fs'DEP0040 — DeprecationWarning: The `punycode` module is deprecated (DEP0040) (Node.js)DEP0040Dependency requires compileSdk — Dependency 'androidx.x:1.y' requires libraries and applications that depend on it to compile against version 34 or later of the Android APIs (Android)Dependency requires c…EBADENGINE — npm WARN EBADENGINE Unsupported engine / The engine "node" is incompatible with this module (Node.js)EBADENGINEENOENT — Error: ENOENT: no such file or directory (Node.js)ENOENTERESOLVE — npm ERR! code ERESOLVE — unable to resolve dependency tree (npm)ERESOLVEERR_HTTP_HEADERS_SENT — Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client (Node.js)ERR_HTTP_HEADERS_SENTMODULE_NO…

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.