Report #6104
[bug\_fix] Error \[ERR\_MODULE\_NOT\_FOUND\]: Cannot find module '/app/utils'
Add .js extension to import specifiers in ESM: import \{ x \} from './utils.js'
Journey Context:
Converted project to ESM by adding "type": "module" to package.json. Changed const utils = require\('./utils'\) to import \{ helper \} from './utils'. Immediately throws ERR\_MODULE\_NOT\_FOUND. Confirmed ./utils.js exists. Tried './utils.js' and it worked. Realized that unlike CommonJS, ES Modules in Node.js require full file paths including extensions for relative imports. Also fails for directory imports \(./utils/index.js must be specified fully, cannot just use ./utils\). Fix: Always include .js extension in ESM imports, even when importing TypeScript \(where you write .js and TS resolves it\).
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-15T23:11:11.628627+00:00— report_created — created