question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Set ERR_PACKAGE_PATH_NOT_EXPORTED code on errors when bailing

See original GitHub issue

Node throws an ERR_PACKAGE_PATH_NOT_EXPORTED error when “Package exports do not define or permit a target subpath in the package for the given module”.

For improved compatibility with the Node ecosystem, I think it would be a good idea for resolve.exports to set error.code to ERR_PACKAGE_PATH_NOT_EXPORTED when bailing, so that packages can continue checking the error code to tell “path not exported” errors apart from other errors.

Ref:

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:2
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
developitcommented, Jan 13, 2021

I think this would be nice. Given that this package is mostly used in cli/tooling/server environments, it feels like it’s worth the extra bytes. It provides for a potential future scenario where resolve() throws an error for some other reason (malformed map key, invalid path value, etc).

For a library, it’d be preferable to avoid subclassing Error though. Just something like Object.assign(Error('xyz'), { code: 'ERR_PACKAGE_PATH_NOT_EXPORTED' }) feels like enough.

0reactions
lukeedcommented, Jan 13, 2021

Thanks! Right, I would just add a code key instead of throwing custom error types.

@paul-soporan already raised #5 for throwing on invalid target(s), but I don’t think resolve() is the right time/place for that. I don’t see this as an "exports" validator utility.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error [ERR_PACKAGE_PATH_NOT_EXPORTED] #142 - GitHub
I keep on getting this error since I installed this module yesterday Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in ...
Read more >
Ask Question - Stack Overflow
I was receiving Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/parser' is not defined by "exports ...
Read more >
suppress bailing out and force the solver to continue
Hi,. I understand that ampl/cplex discards the values of parameters if they are outside of the subscript ranges of the parameters, and return...
Read more >
[err_package_path_not_exported]: package subpath './types ...
This problem can be occur when you are trying to work with an old react repository which is developed with a lower node.js...
Read more >
No "exports" main defined - Laracasts
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined ... <anonymous> (C:\Users\standarduser\code\irp-project\node_modules\@babel\preset-env\lib\ ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found