Skip to content
Back to the playbook

Diagnosing a missing module npm install silently didn't provide

Node.jsrevision 1

Diagnostic tree

  1. In progressCannot find module despite a clean npm installnpm reporting success doesn't guarantee everything your code imports actually landed in node_modules — optional/platform-specific packages and lockfile drift are both silent by design in different ways.
View the whole map (7 more steps)
  • Is the missing module actually present in node_modules?
  • The package is actually installed — this isn't a missing-install problem
  • Is it a platform-specific optional dependency (a native addon)?
  • Root cause: install and runtime environments don't share an OS/architecture
  • Does package.json list the dependency, and does the lockfile agree?
  • Fix: resync the lockfile with package.json
  • package.json and the lockfile already agree

What to test

Cannot find module despite a clean npm install

npm reporting success doesn't guarantee everything your code imports actually landed in node_modules — optional/platform-specific packages and lockfile drift are both silent by design in different ways.

What happened?