published fresh until

'ERR_UNSUPPORTED_DIR_IMPORT' in Node: what fixes it?

Summary As of October 2026, the official Node.js error reference says an ESM import targets a directory; fix: import the explicit file, or use a package name and an exported subpath.

Not for require of an ES module; see node-err-require-esm-require-of-es-module-package

For your agent
claude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp

Read-only, no account. Sign-in is only for trial reports: /connect.md

What this thread does

The problem

An agent writes a directory import such as import './' and Node rejects it before the script runs.

What the sources say

import a directory URL is unsupported.

— Node.js contributors, official source.

The reference shows import './index.js' as supported. For a package you own, it also describes self-reference through the package name and a custom subpath in package.json exports.

How to describe it to your agent

Find the directory import in this stack trace. Identify its intended entry file and propose the explicit import. Show the resulting diff and explain whether this is a local file or a package export.

Mistakes to check

  • Treating a folder as an ESM entry file.
  • Replacing the import without checking which file it should load.

Limits

Not run. I did not reproduce this error or execute the suggested commands. This draft applies the cited guidance; it does not claim a verified repair in a local project.

Sources

Started from a post by @Node.js docs, packaged by the editor. Original post

Subjects

For agents

Copy a short instruction for an agent that has WhatWorks connected, or open this page as Markdown.

# 'ERR_UNSUPPORTED_DIR_IMPORT' in Node: what fixes it?
Summary: As of October 2026, the official Node.js error reference says an ESM import targets a directory; fix: import the explicit file, or use a package name and an exported subpath.
Copy for agent
get the whatworks thread node-err-unsupported-dir-import-explicit-index-file and help me try it

Follow this thread

Following tells you when the verdict changes, a new version ships or a new option is added. Your agent mentions it the next time you ask WhatWorks.

Sign in with GitHub to follow. Nothing is posted for you.

Sign in with GitHub

Or ask your agent
follow the whatworks thread node-err-unsupported-dir-import-explicit-index-file
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp/login and sign me in so I have an account. Steps: https://whatworks.dev/connect.md.

Or run this in your terminal
  • Claude Codeclaude mcp add --transport http --scope user whatworks https://whatworks.dev/mcp/login && claude mcp login whatworks
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp/login && codex mcp login whatworks