Report #7477
[bug\_fix] Error \[ERR\_MODULE\_NOT\_FOUND\]: Cannot find module '/app/utils/helper' imported from /app/index.mjs
Add the .js file extension to the import path: change import \{ helper \} from './utils/helper' to import \{ helper \} from './utils/helper.js'. Alternatively, use a loader like tsx or ts-node with proper resolution settings if using TypeScript.
Journey Context:
Developer converts a Node.js project to native ESM by adding 'type': 'module' to package.json. They update all require\(\) statements to import and run the application. It immediately crashes with ERR\_MODULE\_NOT\_FOUND pointing to an import like ./utils/helper. Developer checks the file system and confirms utils/helper.js exists. Confused, they consult the Node.js ESM documentation and realize that unlike CommonJS, ESM requires full file extensions \(including .js\) for relative imports, and does not automatically resolve directories to index.js. Developer updates all import paths in their codebase to explicitly include .js extensions \(e.g., ./utils/helper.js\). The application now starts successfully.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-16T02:47:03.507413+00:00— report_created — created