-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in package.json #382
Comments
Can't tell what is wrong. |
No looking as zx issue, |
@antonmedv The structure of |
IDK |
Can't repoduce. |
What did you try to reproduce? Here is a detailed reproduction using Node 14 and Node 17:
|
Node 14 not supported. |
It is also is reproducible using 16 and 17 (as shown above for 17). |
Let me again |
Debugged. zx does not provide CJS version starting with v6. The error ERR_PACKAGE_PATH_NOT_EXPORTED, is thrown by using require() on zx. This is not supported by node. Use import(). You can try this: console.log(await import.meta.resolve('zx'));
|
Thanks for debugging. I think it is supported as you can see in this ESM documentation: https://nodejs.org/api/module.html#modulecreaterequirefilename I am not calling require, I'm only using its Unfortunately I can't use |
Can't tell why zx does not work the same way. ¯_(ツ)_/¯ |
Maybe we will one day figure it out, thanks for the time and help :). |
@antonmedv I may have found the issue. When I edit
it starts working. That seems more like the schema they describe here: |
I see. But we can't ditch types. Also conditional exports possible: https://nodejs.org/api/packages.html#conditional-exports which zx uses. Two possible ways: maybe an issue in require.resolve? Or how to define types not in exports? |
You're right, I missed that. I'll file a bug with Node.js. |
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. |
I can use https://github.com/wooorm/import-meta-resolve as a workaround. |
All fixed now, nbb 0.3.7 works with zx 6.0.0+: (ns script
(:require ["zx" :refer [$]]
[nbb.core :refer [await]]))
(await ($ #js ["ls" "-la"]))
(prn :foo 1 2 3) |
Is there any workaround for this issue? (Why did the issue get closed?) I can reproduce the issue with the latest versions (node: 16.4.1, zx: v6.1.0). Thanks. |
@akefirad Can you make a repro? How are you using zx?
|
There you go: zx-bug.zip. Forgot to mentioned I'm using it via |
I confirm the same issue on the latest version, version 4.3 works fine |
@LeonAlvarez How are you using zx? Can you create a package.json + code sample? |
I've run into this issue trying to use zx with gatsby (which appears to have some trouble with ESM) Are newer versions of code sample: https://stackblitz.com/edit/node-rzx94p?file=index.js |
node:internal/errors:464
ErrorCaptureStackTrace(err);
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /app/node_modules/zx/index.mjs not supported.
Instead change the require of /app/node_modules/zx/index.mjs to a dynamic import() which is available in all CommonJS modules.
at file:///app/build/scripts/start.mjs:3:23
at async importPath (file:///app/node_modules/zx/zx.mjs:128:3)
at async main (file:///app/node_modules/zx/zx.mjs:50:7)
at async file:///app/node_modules/zx/zx.mjs:26:1 {
code: 'ERR_REQUIRE_ESM'
}
npm notice
npm notice New major version of npm available! 7.21.0 -> 8.9.0
npm notice Changelog: https://github.com/npm/cli/releases/tag/v8.9.0
npm notice Run npm install -g npm@8.9.0 to update!
npm notice
node:internal/errors:464
ErrorCaptureStackTrace(err);
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /app/node_modules/zx/index.mjs not supported.
Instead change the require of /app/node_modules/zx/index.mjs to a dynamic import() which is available in all CommonJS modules.
at file:///app/build/scripts/start.mjs:3:23
at async importPath (file:///app/node_modules/zx/zx.mjs:128:3)
at async main (file:///app/node_modules/zx/zx.mjs:50:7)
at async file:///app/node_modules/zx/zx.mjs:26:1 {
code: 'ERR_REQUIRE_ESM'
}
node:internal/errors:464
ErrorCaptureStackTrace(err);
^
Error [ERR_REQUIRE_ESM]: require() of ES Module /app/node_modules/zx/index.mjs not supported.
Instead change the require of /app/node_modules/zx/index.mjs to a dynamic import() which is available in all CommonJS modules.
at file:///app/build/scripts/start.mjs:3:23
at async importPath (file:///app/node_modules/zx/zx.mjs:128:3)
at async main (file:///app/node_modules/zx/zx.mjs:50:7)
at async file:///app/node_modules/zx/zx.mjs:26:1 {
code: 'ERR_REQUIRE_ESM'
} Still facing this issue :( |
|
In a reference repro this commit was enough to get a vanilla npm+typescript project to execute zx scripts with ts-node. More in the PR |
Hi team, is there any update regarding this issue? I appreciate that people might be busy with other stuff, but we were asked to provide sample code to reproduce it, but didn't get any reply. Thanks. 🙏 |
Nbb, 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:
This code worked in zx 5.3.0 but stopped working in 6.0.7 with the following error:
The text was updated successfully, but these errors were encountered: