ERR_MODULE_NOT_FOUND
node
module_error
ai_generated
true
Error [ERR_MODULE_NOT_FOUND]: Cannot find module
ID: node/err-module-not-found
87%Fix Rate
89%Confidence
340Evidence
2023-01-01First Seen
Version Compatibility
| Version | Status | Introduced | Deprecated | Notes |
|---|---|---|---|---|
| 20 | active | — | — | — |
Root Cause
Node.js cannot resolve the specified module. Common with ESM/CJS conflicts or missing dependencies.
genericWorkarounds
-
92% success Run npm install to ensure all dependencies are installed
rm -rf node_modules && npm install
Sources: https://docs.npmjs.com/cli/v10/commands/npm-install
-
85% success Check package.json exports field matches the import path
Check package.json exports field matches the import path
Sources: https://nodejs.org/api/packages.html#package-entry-points
Dead Ends
Common approaches that don't work:
-
Add .js extension to import
60% fail
Only works for local files, not for node_modules
-
Switch type in package.json between module and commonjs
68% fail
May break other imports throughout the project
Error Chain
Preceded by:
Frequently confused with: