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

Fixes

  1. 1. Install dependencies
    npm install
  2. 2. Use correct import for ESM
    import xxx from 'xxx';  // or dynamic: await import('xxx')
  3. 3. Clear and reinstall
    rm -rf node_modules package-lock.json && npm install

Still not fixed?

Related Errors

DuskTools That Might Help

All Errors