TraceResolveSRE Platform
MCP ServerAdmin
Back to CatalogNode.js / TypeScript

Node.js: Error [ERR_MODULE_NOT_FOUND]: Cannot find module without file extension in Node ESM

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/src/utils' imported from /app/src/index.js Did you mean to import /app/src/utils.js?
Immediate Remediation
typescript
// 1. In tsconfig.json: Use NodeNext or Bundler module resolution:
{
  "compilerOptions": {
    "moduleResolution": "bundler",
    "module": "ESNext"
  }
}

// 2. In Node runtime ESM: Always include explicit .js extension in relative imports:
import { helper } from './utils.js';
Root Cause Analysis

Node.js native ECMAScript Modules (ESM) specification does not perform automatic directory index or extension resolution (unlike CommonJS or Webpack).

Verification & Guardrails

  • In TypeScript with moduleResolution "NodeNext", import statements must reference .js even though the source is .ts.
  • Use moduleResolution "bundler" if targeting Next.js, Vite, or Cloudflare Workers.

Have a custom or uncategorized crash?

Run your trace through our in-memory client privacy sandbox for instant SRE remediation.

Open Diagnostic Studio