Skip to content

module: missing path separator in ERR_PACKAGE_PATH_NOT_EXPORTED message from CJS #34778

@targos

Description

@targos
  • Version: v14.8.0
  • Platform: Windows
  • Subsystem: module

This happens only if a package is required from CommonJS.
Can be reproduced with the following structure:

node_modules/test-module/package.json:

{
  "exports": {
    ".": "./index.js"
  }
}

test.js:

require('test-module/wrong-path')

Error:

> node test.js
internal/modules/cjs/loader.js:518
  throw new ERR_PACKAGE_PATH_NOT_EXPORTED(basePath, mappingKey);
  ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './wrong-path' is not defined by "exports" in D:\Git\test\node_modules\test-modulepackage.json
    at applyExports (internal/modules/cjs/loader.js:518:9)
    at resolveExports (internal/modules/cjs/loader.js:534:23)

There should be a path separator between test-module and package.json in the error message.

Metadata

Metadata

Assignees

No one assigned

    Labels

    moduleIssues and PRs related to the module subsystem.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions