Node.js
Error: Cannot find module 'xxx'
Cannot Find Module
Node.js cannot resolve the required module. Common with missing dependencies or wrong paths.
Common Causes
- Package not installed (npm install missing)
- Wrong require path (relative vs package name)
- Module is ESM but required with require()
- node_modules corrupted or incomplete
Fixes
- 1. Install dependencies
npm install
- 2. Use correct import for ESM
import xxx from 'xxx'; // or dynamic: await import('xxx') - 3. Clear and reinstall
rm -rf node_modules package-lock.json && npm install
Still not fixed?
- • Search the exact error message on Stack Overflow or GitHub Issues
- • Check the official docs for the language or tool
- • Ensure your versions (Node, Python, npm, Docker) are up to date
- • Try in a minimal reproduction (new project, single file)
Related Errors
DuskTools That Might Help
All Errors
JavaScript Heap Out of MemoryModuleNotFoundErrorAddress Already in UseIndentationErrorPeer Dependency WarningCORS Policy BlockedTypeError: 'NoneType' Not SubscriptableMerge ConflictDocker Port Already AllocatedENOENT: No Such File or DirectoryKeyErrorMaxListenersExceededWarningRecursionErrorDetached HEAD StateEACCES: Permission DeniedValueErrorNo Space Left on DeviceERR_REQUIRE_ESMFileNotFoundError