Short answer
If the message says Cannot find module with a path, add the file extension to the import (./utils.js); a bare directory import gives ERR_UNSUPPORTED_DIR_IMPORT instead and needs ./lib/index.js. In TypeScript with "module": "NodeNext", write the .js extension in the .ts source; the compiler keeps it. If it says Cannot find package, install it (and check it is in dependencies, not devDependencies, when production installs skip dev packages). On Linux servers, also check the letter case of the file name.
Rather not fix it yourself? App Fix Ticket fixes one reproducible bug at a fixed price, with an optional Diagnosis that is credited toward the fix.
What the import points at, and the fix
01
A relative import without the file extension
“A file extension must be provided when using the import keyword to resolve relative or absolute specifiers.” Node.js, ECMAScript modules: mandatory file extensions
import './utils' works with bundlers and require(), but not with Node.js ES modules. Add the extension. A directory import such as './lib' fails with a different error, ERR_UNSUPPORTED_DIR_IMPORT, and needs './lib/index.js'.
// wrong import { slugify } from './utils'; // right import { slugify } from './utils.js'; import { db } from './lib/index.js';02
TypeScript output without extensions
TypeScript does not add extensions when it compiles. With "module": "NodeNext", write imports with .js in your .ts files (TypeScript resolves them to the .ts source), so the compiled output is valid for Node.js. TypeScript 5.7 and newer can instead rewrite .ts imports with rewriteRelativeImportExtensions.
// src/index.ts import { slugify } from './utils.js'; // points at src/utils.ts03
A deep import into a package
“Directory indexes (e.g. './startup/index.js') must also be fully specified.” Node.js, ECMAScript modules: mandatory file extensions
import 'lodash/get' gives Cannot find module '.../node_modules/lodash/get' when the package has no exports map for that path. Add the extension (lodash/get.js), or import from the package entry point.
04
Cannot find package: not installed where it runs
The package is missing from node_modules in the folder that runs the code: a production install that skips devDependencies, a Docker image that copied the code but not node_modules, or a monorepo package that does not list the dependency itself. Add it to that package’s dependencies and reinstall.
npm ls express npm install express05
Letter case on Linux
macOS and Windows usually ignore the difference between Utils.js and utils.js; Linux servers and CI do not. Match the import to the file name exactly.
Checked against the vendor’s docs on : Node.js: ECMAScript modules (mandatory file extensions).
Rather hand it over?
Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.
- from $450App Fix TicketOne reproducible bug. The Fix costs $1,200. If you need a Diagnosis first, its $450 fee counts toward the Fix.See scope and start
- from $450AI-Built App RescueFor a whole-app review, the $450 Launch Check is credited toward the optional $1,950 Rescue Sprint for up to five critical or high findings.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
“Very responsive, attentive to fixing bugs, and completed the project as needed! Thank you!”
Related: Node.js “Cannot find module” · Node.js “Cannot use import statement outside a module” · Vercel “Module not found: Can’t resolve” · Node.js ERR_INVALID_ARG_TYPE