Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
targos opened this issue Aug 14, 2020 · 3 comments
Closed
Labels
module Issues and PRs related to the module subsystem.

Comments

@targos
Copy link
Member

targos commented Aug 14, 2020

  • 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.

@targos targos added the module Issues and PRs related to the module subsystem. label Aug 14, 2020
@guybedford
Copy link
Contributor

@targos this looks like it was fixed in the recent refactoring on master.

@guybedford
Copy link
Contributor

I tested this against master and can confirm it is fixed there in #34744. Please reopen if I've missed anything though.

@targos
Copy link
Member Author

targos commented Aug 15, 2020

Thanks for verifying!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module Issues and PRs related to the module subsystem.
Projects
None yet
Development

No branches or pull requests

2 participants