Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main resolved in /app/node_modules/@babel/helper-compilation-targets/package.json
Using npm update
fixed the same error for me.
I had the similar problem. npm install @babel/helper-compilation-targets --save-dev
solved this situation
I was experiencing this issue and I resolved it by removing the lock file and then reinstall everything again.
This is probably not a good solution for everyone but it works for me.
Here's exactly what I have done.
- Removing the lock file. In this case I'm using
yarn
so I need to delete theyarn.lock
file. If you're usingnpm
the lock file ispackage-lock.json
.
# for yarn user
rm yarn.lock
# for npm user
rm package-lock.json
- And then I reinstall all the dependencies.
# for yarn user
yarn install
# for npm user
npm install
The solution that worked for me was simply to update node.
For, example, using node 12.22.0 worked, as well as 14.17.4. Note that node version of 13.x will not work at all.
I was also having this issue and found out that this error seems to be specific to some node js versions.
- node 13.14.0, node 12.18.4, 12.19.0, 12.19.1 show the error : ERR_PACKAGE_PATH_NOT_EXPORTED
- With node 12.20.0, node 14.17.4, the error is not thrown.
The issue is that a new system for exports has been created, as defined here :
https://github.com/nodejs/modules/issues/535
This feature allows to define the allowed requires that are possible in a package using globs, like this :
"exports": {
".": {
"import": "./dist/pako.esm.mjs",
"require": "./index.js"
},
"./package.json": "./package.json",
"./dist/*": "./dist/*",
"./lib/*": "./lib/*",
"./lib/zlib/*": "./lib/zlib/*",
"./lib/utils/*": "./lib/utils/*"
},
The pull request for this feature can be found here : https://github.com/nodejs/modules/issues/535
Now if you include a package that uses this new "glob" feature in the exports file, it can fail if you require that specific file.
fixed by npm update && npm audit fix --force