Short answer
Read the name in quotes. If it is a package name (like 'express'), run npm install in the folder that holds package.json, and check the package is under dependencies, not only devDependencies, if production installs skip dev packages. If it is a path ('./utils/db' or '/app/dist/index.js'), check the file exists at that path with that exact case, and that the build step that creates it ran. If it started after a Node.js upgrade, delete node_modules and run npm ci.
Why Node.js can’t find it, and the fix
01
The package is not installed where the code runs
“If it is not found there, then it moves to the parent directory, and so on, until the root of the file system is reached.” Node.js, Modules: CommonJS modules
For a bare name like 'express', Node.js walks up from the current file through every node_modules folder to the root of the disk. If the package is not in any of them, the error appears. This is common after cloning a repo, after switching branches that changed package.json, or on a server where the install ran in a different folder.
# in the folder that holds package.json npm install # a single missing package npm install express02
Production skipped devDependencies
Hosts and Docker images often install with npm ci --omit=dev or NODE_ENV=production. Anything the running app needs at runtime must be in dependencies. A package used only by the build (TypeScript, a bundler) can stay in devDependencies if the build runs before the dev packages are dropped.
# move a runtime package to dependencies npm install --save-prod dotenv03
The relative path is wrong
A name starting with ./ or ../ is resolved from the folder of the file that contains the require, not from where you started node. Check the spelling and the case: macOS ignores case by default, but Linux servers and most CI do not, so ./Utils/db works on a Mac and fails on deploy. With ES modules (import), include the file extension, such as ./db.js.
04
The entry file is not built yet
Errors like Cannot find module '/app/dist/index.js' mean the start command points at build output that does not exist. Run the build before start (npm run build, then npm start), check the outDir in tsconfig.json matches the path in package.json, and make sure the build output is not excluded from the deploy.
// package.json "scripts": { "build": "tsc", "start": "node dist/index.js" }
Checked against the vendor’s docs on : Node.js: Modules: CommonJS modules (loading from node_modules folders); Node.js: Errors (MODULE_NOT_FOUND).
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug in an existing mobile or web app, diagnosed and fixed.See scope and start
- from $450AI-Built App RescueA Lovable, Bolt or Cursor app checked end to end in 3 days, then its worst problems fixed at a fixed price.No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.See scope and start
Related: “Cannot use import statement outside a module” · Vercel “Module not found: Can’t resolve” · Node.js ENOENT: no such file or directory · Node.js ERR_MODULE_NOT_FOUND