node module_error ai_generated true

Error: Cannot find module

ID: node/cannot-find-module-npm

Also available as: JSON · Markdown
90%Fix Rate
91%Confidence
295Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
20 active

Root Cause

Module not found in node_modules or local paths. Most common Node.js error.

generic

Workarounds

  1. 92% success Delete node_modules and package-lock.json then reinstall
    rm -rf node_modules package-lock.json && npm install

    Sources: https://docs.npmjs.com/cli/v10/commands/npm-install

  2. 88% success Check the module name for typos in require/import statement
    Check the module name for typos in require/import statement

    Sources: https://nodejs.org/api/modules.html#all-together

Dead Ends

Common approaches that don't work:

  1. Manually copy the module file into node_modules 85% fail

    Will be overwritten on next npm install

  2. Create a symlink to the module 72% fail

    Fragile and breaks on different machines

Error Chain

Leads to:
Preceded by:
Frequently confused with: