[ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in package.json
See original GitHub issueNbb, a ClojureScript interpreter for Node.js uses dynamic import to load libraries. To resolve which JS file to load, it uses code like the following:
import { createRequire } from 'module';
const req = createRequire(import.meta.url);
console.log(req.resolve('zx'));
This code worked in zx 5.3.0 but stopped working in 6.0.7 with the following error:
$ node script.mjs
path
node:internal/errors:465
ErrorCaptureStackTrace(err);
^
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /private/tmp/test-nbb/node_modules/zx/package.json
at new NodeError (node:internal/errors:372:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:433:9)
at packageExportsResolve (node:internal/modules/esm/resolve:657:7)
at resolveExports (node:internal/modules/cjs/loader:482:36)
at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.resolve (node:internal/modules/cjs/helpers:108:19)
at file:///private/tmp/test-nbb/script.mjs:6:17
at ModuleJob.run (node:internal/modules/esm/module_job:197:25)
at async Promise.all (index 0) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
}
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:29
Top Results From Across the Web
No "exports" main resolved in /app/node_modules/@babel ...
If you're using npm the lock file is package-lock.json . ... The issue is that a new system for exports has been created,...
Read more >Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No 'exports'
Run the npm update command to solve the "Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No 'exports'" and then run npm audit fix --force if necessary.
Read more >Error [ERR_PACKAGE_PATH_NOT_EXPORTED] #142 - GitHub
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in .../node_modules/jose/package.json means you're doing require/import of just ...
Read more >No "exports" main defined - Laracasts
Hello , After cloning my project I got the error bellow when I npm run watch (I deleted the node_modules) ERROR in ./resources/js/app.js...
Read more >No "exports" main resolved in@babel/helper-compilation ...
Coding example for the question Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main resolved in@babel/helper-compilation-targets/package.json-babel.js.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I confirm the same issue on the latest version, version 4.3 works fine
Now I’m not sure if this is a Node.js bug either since when I add:
then it also works again. I guess I’m stuck for now then, until I can use import.meta.resolve.