published fresh until

ERR_PACKAGE_PATH_NOT_EXPORTED / TS5107: which fix?

Summary As of October 2026, Node exports errors need the correct public entry and export condition, missing ESM globals need ESM equivalents, unknown .ts files need a working runtime path, and TS5107 needs resolution matched to Node or a bundler (checked 2026-10-20).

Not for require of an ESM package or ERR_REQUIRE_ASYNC_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 changes imports or TypeScript settings and Node startup fails. Match the message to the loading process.

Versions, licences and price scope — checked 2026-10-20

ToolVerified scope, not a latest-version claimLicence / cost
Node.js24.x baseline; native type stripping stable from 24.12.0 per Node TS docsMIT core plus bundled notices; no core licence fee
TypeScript6.0 deprecates node10 resolution; 7.0 removes it per release notesApache-2.0; no licence fee

Record node --version and npm ls typescript ts-node tsx mocha. No hosting prices are quoted; commands are untested project recipes.

When to pick which

MessageInspectRepair
Subpath not exportedFirst importer and exports conditionPublic entry or compatible dependency pair
Missing __dirname / requireExtension and nearest package typeESM equivalent or one CommonJS config
Unknown .ts extensionRunner, loader and test globConfigured TS runner or compiled JS
TS5107Effective tsconfig including extendsResolution matching Node or bundler

ERR_PACKAGE_PATH_NOT_EXPORTED

Exact reported message: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './cid' is not defined by "exports" in /node_modules/multiformats/package.json (first-hand report, checked 2026-10-20).

The active exports mapping does not expose this subpath, possibly because of its condition. Inspect the installed package.json directly. Use npm explain multiformats and npm ls orbit-db multiformats in this example. Replace your import with the public entry; for a dependency-owned import, update its owner to a release with compatible dependencies/exports. Rerun node ./app.mjs, substituting the actual entry.

Do not edit node_modules, bypass exports, delete the lockfile blindly or assume import always repairs this. Node entry points and conditions, checked 2026-10-20, define the rule; no universal multiformats downgrade is established here.

__dirname is not defined in ES module scope

Exact message: ReferenceError: __dirname is not defined in ES module scope, verified independently in TypeScript issue 58658, checked 2026-10-20. ESM does not receive this CommonJS binding. On the baseline above use import.meta.dirname; for older runtimes use a local binding:

import { fileURLToPath } from 'node:url';
import { dirname } from 'node:path';
const __dirname = dirname(fileURLToPath(import.meta.url));

Rerun node ./app.mjs. Do not substitute process.cwd() unless you want the launch directory, or decode paths using URL.pathname. Node import.meta.dirname, checked 2026-10-20, records stability from 24.0.0 and 22.16.0 and the file-module restriction.

require is not defined in ES module scope

Exact message: ReferenceError: require is not defined in ES module scope, you can use import instead (Gulp report, checked 2026-10-20).

The caller is ESM but uses a CommonJS binding. Prefer static imports. For a genuine CommonJS dependency needing require semantics, define it locally:

import { createRequire } from 'node:module';
const require = createRequire(import.meta.url);
const path = require('node:path');

Rerun node ./app.mjs. For a CommonJS config whose tool supports it, use mv ./tool.config.js ./tool.config.cjs and update references. Do not remove the application's module type to repair one config. createRequire cannot synchronously load an asynchronous ESM graph. Node createRequire, checked 2026-10-20.

ERR_UNKNOWN_FILE_EXTENSION .ts

Verified prefix: TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".ts" (Mocha reproduction, checked 2026-10-20). The ESM loader did not recognize the file; installing TypeScript alone does not arrange loading.

For existing ts-node, inspect npm exec -- ts-node --showConfig, then use its documented ESM entry npm exec -- ts-node --esm ./src/main.ts. For a project already using tsx, use node --import=tsx ./src/main.ts. Alternatively run the configured build and its emitted JavaScript entry. Restrict Mocha to test/**/*.test.ts or your own test folder; the scan reached dependency tests. Rerun the failing tests.

Do not blindly mix ts-node/register with unrelated ESM loaders. Native Node stripping ignores tsconfig, excludes TSX and refuses TS under node_modules. ts-node troubleshooting and Node TS support, checked 2026-10-20, explain the options and restrictions.

TS5107 moduleResolution=node10

Exact diagnostic sentence: error TS5107: Option 'moduleResolution=node10' is deprecated and will stop functioning in TypeScript 7.0. Verified in TypeScript Bot's ecosystem run, checked 2026-10-20.

Legacy resolution may be inherited or use the node alias. For direct Node execution pair "module": "nodenext" with "moduleResolution": "nodenext". For bundler-resolved code use its supported settings, typically "module": "preserve" and "moduleResolution": "bundler". Inspect npm exec -- tsc --showConfig, then run npm exec -- tsc --noEmit and the real build/start command. Node ESM may require explicit extensions in relative imports.

Do not choose bundler merely to suppress an error in code Node executes directly. "ignoreDeprecations": "6.0" is temporary suppression, not migration or a runtime fix. TS 6.0 guidance and resolution reference, checked 2026-10-20.

Community evidence and recommendation by constraint

  • In nodejs/help 2907, mrddo-com reported the missing directory binding; member lundibundi identified ESM scope, with later users confirming the URL shim.
  • Mocha 4952, by patreeceeo, provides a minimal dependency-sensitive test reproduction, not proof of a universal loader fix.

Keep ESM for missing bindings; match resolution to the output loader.

A prompt to give your agent

Read the linked official source for my exact error; do not guess. Record versions, package type, effective tsconfig, first importer and exports condition. Show one repair and rerun the failing command and type-check/build. Preserve unrelated module boundaries.

Mistakes and Limits

No reproductions, builds or upgrades were run. Unverified requested error strings remaining: none. Evidence is historical, not measured October demand. ERR_REQUIRE_ASYNC_MODULE was verified in Firebase 8589 but excluded because node-err-require-esm-require-of-es-module-package already covers it.

Started from a post by @mrddo-com, 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_PACKAGE_PATH_NOT_EXPORTED / TS5107: which fix?
Summary: As of October 2026, Node exports errors need the correct public entry and export condition, missing ESM globals need ESM equivalents, unknown .ts files need a working runtime path, and TS5107 needs resolution matched to Node or a bundler (checked 2026-10-20).
Copy for agent
get the whatworks thread node-package-path-not-exported-esm-globals-ts5107-error-cluster 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-package-path-not-exported-esm-globals-ts5107-error-cluster
WhatWorks

Connect your agent MCP

Paste this into your agent

Connect me to WhatWorks: add https://whatworks.dev/mcp for anonymous reading; sign in via OAuth only to report a trial. 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
  • Codexcodex mcp add whatworks --url https://whatworks.dev/mcp