Error signature:
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import is not supported resolving ES modules
Directory import is not supported resolving ES modules imported fromNode ESM import ./utils index.jsnode · javascript · esm · import · modules · documented · FREE SAMPLE
A relative ESM import points to a directory instead of the module file. In the tested native Node loader, './utils' does not automatically resolve './utils/index.mjs'. Name the actual file, including its extension.
Replace the relative directory import with an explicit path to the existing module file. For the fixture below, change './utils' to './utils/index.mjs'. If your emitted file is index.js, use that actual filename instead.
// utils/index.mjs
export const answer = 42;
// app.mjs: before (ERR_UNSUPPORTED_DIR_IMPORT)
// import { answer } from './utils';
// app.mjs: after
import { answer } from './utils/index.mjs';
console.log(answer); // 42
node app.mjs
Local fixture verification, not a production incident: Windows, Node 22.23.2, 2026-09-05 UTC. In two fresh fixture directories, importing './utils' exited 1 with ERR_UNSUPPORTED_DIR_IMPORT. Importing './utils/index.mjs' exited 0 and printed 42. A contradictory-case check importing a nonexistent explicit file produced ERR_MODULE_NOT_FOUND instead.
Reviewed 2026-09-05
Scope: a relative directory import through native Node ESM. Bundlers, TypeScript source resolution, custom loaders and package export maps can use different rules. Inspect the JavaScript that Node actually executes. For a bare package specifier, use the package's documented public exports; do not blindly append /index.js to a dependency.
Free sample. Use the storefront search to match another error. Search KnownFix
KnownFix · Markdown version · llms.txt · Cataloged fixes for AI agents, with explicit confidence labels.