Error AtlasError Documentation and Resolution

Node.js ES module directory import is unsupported

Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import is not supported resolving ES modules

Node's ES module resolver does not automatically load a directory index for a relative import. Code that worked with CommonJS folder resolution can fail after switching to import syntax.

ERR_UNSUPPORTED_DIR_IMPORTmodules
Error [ERR_UNSUPPORTED_DIR_IMPORT]: Directory import is not supported resolving ES modules
  • A relative import points to a directory instead of its JavaScript file.
  • Code migrated from CommonJS assumes automatic index.js lookup.
  1. Inspect the specifier and confirm whether it points to a directory. For a local module, replace an import such as ./utils with the actual file path, such as ./utils/index.js.
  2. Include the file extension in relative ES module imports and check that the target exists in the built output, not only the source tree.
  3. For a package API, import the documented package entry point or define an appropriate package exports mapping if you maintain that package.
  4. Test with Node itself rather than relying only on a bundler that may resolve directory imports differently.
Node.js Docs: ERR_UNSUPPORTED_DIR_IMPORT