Common causes
- npm install was never run, or ran in a different folder, so node_modules is missing the package
- The package is in devDependencies and the server installed with --omit=dev (or NODE_ENV=production)
- The entry file has not been built yet (dist/ or build/ missing), or the start script points at the wrong file
- ES modules require full file extensions: import './utils' must be './utils.js'
- Case mismatch ('./Utils' vs './utils.js') that macOS/Windows ignore but Linux servers do not
- Running node from the wrong directory with a relative path, or a broken node_modules after switching Node versions
How to fix it
- Tell package vs path apart. A bare name ('express', '@prisma/client') is a package; something starting with ./, ../ or / is a file. The fix differs for each.
- Install the missing package. In the folder containing package.json, run npm install express (saving it to dependencies) or npm ci to install from the lock file. Check it appears in dependencies, not only devDependencies, if production needs it.
- Build before starting. If the missing path is dist/index.js or build/server.js, run npm run build first, and make sure your host's start command or PM2 config points at the built file.
- Fix ESM paths and extensions. In "type": "module" projects, write import { x } from './utils.js' with the extension and use the exact file name case. Directory imports need './utils/index.js'.
- Check case on Linux. Compare the import with ls output exactly. Use git mv to rename files when only the case changes, since Git on macOS/Windows may not record case-only renames.
- Reinstall cleanly. If the package is listed and installed but still missing, delete node_modules and run npm ci; native modules built for another Node version can also fail to load.
Shell
cd /home/user/app # folder with package.json
npm ls express # is it installed here?
npm install express # adds to dependencies
# production install from lock file
npm ci --omit=dev
npm run build && node dist/index.js How to stop it happening again
- Run npm ci in deployments and keep runtime packages in dependencies
- Keep file names lowercase and use a linter rule that checks import paths
- Develop in the same OS as production (Docker or WSL) to catch case issues early