Skip to content

package.json ./testing subpath export points to non-existent path — ERR_MODULE_NOT_FOUND #342

Description

@zoe-codez

Summary

import { TestRunner } from "@digital-alchemy/core/testing" throws ERR_MODULE_NOT_FOUND under Node.js ESM. The exports map in package.json targets a path that does not exist in the published dist/.

Affected version

@digital-alchemy/core 26.6.21
Runtime: node v24.17.0

Symptom

Error [ERR_MODULE_NOT_FOUND]: Cannot find module
  '.../@digital-alchemy/core/dist/testing/helpers/index.mjs'
  imported from <consumer>.mjs

Any test or consumer importing TestRunner (or createMockLogger) via the @digital-alchemy/core/testing subpath fails to load under Node's exports resolver.

Root cause

package.json exports field contains a stale extra helpers/ path segment:

"./testing": "./dist/testing/helpers/index.mjs"

The mapped target ./dist/testing/helpers/index.mjs does not exist — there is no dist/testing/helpers/ directory in the published package.

The real barrel does exist at ./dist/testing/index.mjs (re-exports mock-logger and test-module), with types alongside at ./dist/testing/index.d.mts.

Proposed fix (one line in package.json)

Before:

"./testing": "./dist/testing/helpers/index.mjs"

After:

"./testing": "./dist/testing/index.mjs"

The export target is a bare string, so this single correction resolves both the runtime .mjs and the TypeScript moduleResolution: node16/bundler types via the adjacent ./dist/testing/index.d.mts — no conditional import/types object needed.

Verification

After patching exports, a bare Node ESM import should resolve cleanly:

node --input-type=module -e \
  'import("@digital-alchemy/core/testing").then(m => console.log(Object.keys(m)))'
# expected: [ 'createMockLogger', 'TestRunner' ]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions