Error in `exports` definition in `package.json`
Closed this issue · 1 comments
nicolas-duvauchel commented
dom-accessibility-api version: 0.4.2
node version: v13.11.0
Pulled this library by depending on @testing-library/react
and then got an error trying to run my tests with mocha:
Error [ERR_INVALID_PACKAGE_TARGET]: Invalid "exports" main target "dist/index.js" defined in the package config /Users/...snip.../node_modules/dom-accessibility-api/package.json
at resolveExportsTarget (internal/modules/cjs/loader.js:574:13)
at resolveExportsTarget (internal/modules/cjs/loader.js:613:20)
After a bit of investigation, I believe that the issue is with the exports
values in package.json
missing a leading ./
Changing the exports to the following fixes my issue:
"exports": {
"import": "./dist/index.mjs",
"require": "./dist/index.js"
}
I have to admit I'm not too familiar with this setting but looking at https://nodejs.org/api/esm.html#esm_package_exports this seems correct.
Let me know if you need more details.
eps1lon commented
I can reproduce it. Thanks for the report. Fix is underway.