Report #15389
[bug\_fix] Cannot find module 'X' after npm install / Module did not self-register
Delete node\_modules and package-lock.json \(or yarn.lock/pnpm-lock.yaml\), clear npm cache with npm cache clean --force, then reinstall dependencies. This resolves cache corruption or lockfile desynchronization issues.
Journey Context:
Developer pulls latest main branch after a teammate updated dependencies. Runs npm install, which completes without error. Attempts to run the application and gets Error: Cannot find module 'express' even though express is listed in package.json. Developer checks node\_modules and sees the express folder exists but contains no index.js or the main entry is missing. Realizes the previous npm install was interrupted or the lockfile is out of sync with the actual package versions in the registry. Developer tries npm install again, but npm sees node\_modules exists and lockfile is present, so it skips installation. Developer must force a clean state by deleting node\_modules and package-lock.json, then clearing the npm cache to ensure no corrupted tarballs are reused, then running a fresh npm install which downloads clean copies of all dependencies.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T23:54:01.628631+00:00— report_created — created