# Node.js: “Error [ERR_MODULE_NOT_FOUND]: Cannot find module... imported from...”

> Error [ERR_MODULE_NOT_FOUND]: Cannot find module or package imported from. ES modules need the .js extension, full index paths and installed packages.

Canonical: https://app369.com/fix/node-err-module-not-found/
Last updated: 2026-11-08

An ES module app fails with Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/dist/utils' imported from /app/dist/index.js, or Cannot find package 'express' imported from .... Unlike require(), import in Node.js does not guess file extensions or index files, and it only finds packages that are installed where the importing file can see them.

**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.

## **What the import points at, and the fix**

1. 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**](https://nodejs.org/api/esm.html) 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';
```
2. 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.ts
```
3. 03 ### **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**](https://nodejs.org/api/esm.html) 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.
4. 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 express
```
5. 05 ### **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 November 8, 2026: [Node.js: ECMAScript modules (mandatory file extensions)](https://nodejs.org/api/esm.html).

## **Rather hand it over?**

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

- [from $450**App Fix Ticket**One reproducible bug in an existing mobile or web app, diagnosed and fixed.**See scope and start**](https://app369.com/fixed-price/flutter-firebase-bug-fix/)
- [from $450**AI-Built App Rescue**A 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**](https://app369.com/fixed-price/ai-app-rescue/)

Related: [**Node.js “Cannot find module”**](https://app369.com/fix/node-cannot-find-module/) · [**Node.js “Cannot use import statement outside a module”**](https://app369.com/fix/node-cannot-use-import-statement-outside-module/) · [**Vercel “Module not found: Can’t resolve”**](https://app369.com/fix/vercel-module-not-found-cant-resolve/) · [**Node.js ERR_INVALID_ARG_TYPE**](https://app369.com/fix/node-err-invalid-arg-type/)

Questions

## **More on this error**

<details>

<summary>**Why does it work in Vite or Next.js but not in Node.js? **+</summary>

Bundlers resolve imports without extensions and find index files for you. Node.js running ES modules directly follows the stricter rules, so code that only ran through a bundler breaks when Node.js runs it.

</details>

<details>

<summary>**Is there a flag to make Node.js add extensions? **+</summary>

Not in current versions. Fix the imports, or have your build step rewrite them; TypeScript with NodeNext and most bundlers can produce correct output.

</details>

<details>

<summary>**Can you fix it for me? **+</summary>

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. 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.

</details>

A different error?

## **Describe it and get a written quote**

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; Simon replies by email, usually within one business day.

[**Describe your problem **→](https://app369.com/contact/) [**All fixes**](https://app369.com/fix/)