Node.js Diagnostic

Fix Node.js "Error [ERR_MODULE_NOT_FOUND]: Cannot find module" in ES Modules

When "type": "module" is configured in package.json, Node.js ECMAScript Modules (ESM) resolver strictly requires explicit relative file extensions (.js) and cannot auto-resolve .ts or directories without index.js.

Error [ERR_MODULE_NOT_FOUND]: Cannot find module

Quick Fix Checklist

  1. Always append .js to relative imports when targeting Node ESM (even in TypeScript source files)
  2. Use a bundler (Vite, TSX, esbuild, Rollup) if you desire extensionless imports
  3. Check package.json for "type": "module" and verify path spellings