-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
[BUG] ExperimentalWarning: Support for loading ES Module in require() is an experimental feature and might change at any time #7857
Comments
This is triggered by the experimental |
It's not necessary to install anything with npm to provoke the For example, even with no npm modules installed, executing
Ubuntu Same
|
Setting the environment variable
|
FYI the ESM being |
You're right! Line 113 in 780afc5
where [email protected] and above is pure ESM
const supportsColor = require('supports-color'); where debug is effectively allowing an ESM version of
So I guess the underlying issue debug-js/debug#975 needs to be resolved by debug. |
npm install [email protected] -g and there was no more warning under Node.js npm view npm version |
Why?: Because the following error will happen when running server. ```bash $ npm run dev > [email protected] dev > vite VITE v5.4.9 ready in 310 ms ➜ Local: http://localhost:5173/ ➜ Network: use --host to expose ➜ press h + enter to show help (node:59826) ExperimentalWarning: Support for loading ES Module in require() is an experimental feature and might change at any time (Use `node --trace-warnings ...` to show where the warning was created) file:///home/toor/repos/github.com/rnazmo/my-web-tools/tailwind.config.js:56 plugins: [require("tailwindcss-animate")], ^ ReferenceError: require is not defined at file:///home/toor/repos/github.com/rnazmo/my-web-tools/tailwind.config.js:56:12 at ModuleJobSync.runSync (node:internal/modules/esm/module_job:367:35) at ModuleLoader.importSyncForRequire (node:internal/modules/esm/loader:325:47) at loadESMFromCJS (node:internal/modules/cjs/loader:1392:24) at Module._compile (node:internal/modules/cjs/loader:1525:5) at Object..js (node:internal/modules/cjs/loader:1680:16) at Module.load (node:internal/modules/cjs/loader:1328:32) at Function._load (node:internal/modules/cjs/loader:1138:12) at TracingChannel.traceSync (node:diagnostics_channel:315:14) at wrapModuleLoad (node:internal/modules/cjs/loader:218:24) at Module.require (node:internal/modules/cjs/loader:1350:12) at require (node:internal/modules/helpers:138:16) at /home/toor/repos/github.com/rnazmo/my-web-tools/node_modules/tailwindcss/lib/lib/load-config.js:54:27 at loadConfig (/home/toor/repos/github.com/rnazmo/my-web-tools/node_modules/tailwindcss/lib/lib/load-config.js:58:6) at getTailwindConfig (/home/toor/repos/github.com/rnazmo/my-web-tools/node_modules/tailwindcss/lib/lib/setupTrackingContext.js:71:116) at /home/toor/repos/github.com/rnazmo/my-web-tools/node_modules/tailwindcss/lib/lib/setupTrackingContext.js:100:92 at /home/toor/repos/github.com/rnazmo/my-web-tools/node_modules/tailwindcss/lib/processTailwindFeatures.js:46:11 at plugins (/home/toor/repos/github.com/rnazmo/my-web-tools/node_modules/tailwindcss/lib/plugin.js:38:69) at LazyResult.runOnRoot (/home/toor/repos/github.com/rnazmo/my-web-tools/node_modules/postcss/lib/lazy-result.js:329:16) at LazyResult.runAsync (/home/toor/repos/github.com/rnazmo/my-web-tools/node_modules/postcss/lib/lazy-result.js:258:26) at LazyResult.async (/home/toor/repos/github.com/rnazmo/my-web-tools/node_modules/postcss/lib/lazy-result.js:160:30) at LazyResult.then (/home/toor/repos/github.com/rnazmo/my-web-tools/node_modules/postcss/lib/lazy-result.js:404:17) Node.js v23.0.0 ``` What I did: ```bash $ mise use node@22 ✔mise ~/repos/github.com/rnazmo/my-web-tools/.mise.toml tools: [email protected] $ node --version v22.9.0 ``` Ref: npm/cli#7857 https://mise.jdx.dev/cli/use.html See also: https://tailwindcss.com/docs/configuration
What I did: ```bash $ mise --version 2024.10.7 linux-x64 (7d15bd5 2024-10-14) $ mise ls-remote node | tail -n 5 22.7.0 22.8.0 22.9.0 22.10.0 23.0.0 $ mise use node@22 mise ~/repos/github.com/rnazmo/vite-react-ts-tailwind-template/.mise.toml tools: [email protected] $ node --version v22.9.0 ```` NOTE: Use 22 not 23 because 23 is still new and will cause trouble. Ref: https://mise.jdx.dev/demo.html https://mise.jdx.dev/lang/node.html https://mise.jdx.dev/cli/ls-remote.html https://mise.jdx.dev/cli/use.html npm/cli#7857
Under Node.js
|
Out of nowhere, npm install and npm start doesnt work in my project. I have to downgrade my node version to make it work. |
That sounds like a different issue. This issue is about an |
What can we do other than rewrite everything between npm to debug, inclusive, in ESM? |
@SparK-Cruz you can't do anything, whatsoever. Only node, npm, or |
This comment was marked as off-topic.
This comment was marked as off-topic.
@ljharb We can always open a pull request... if gets approved or not is another story. Worst case scenario I can fork it and add it to the AUR. |
@SparK-Cruz yes, a PR to debug would be a possible path forward. Forking things to AUR without the consent of the maintainer doesn’t actually help the ecosystem, though, and it makes things worse for AUR users because they’re not really using the actual software. |
Hm, I think the cause of this is npm cli directly depending on a different major version of |
I opened a PR with a really simple approach to fix it from supports-color side, by adding an automation to also export the index.js (ESM) to index.cjs. This allows the supports-color to support both Also, no changes would be necessary either on the debug or npm/cli side (except maybe forcing an update to the new supports-color version, if approved). EDIT: Unfortunately, supports-color's decision is in fact not to be compatible with |
I get this error on
I was only able to publish by using node 22. |
@damisparks node v23.0.0 is broken, so you'd need to be on v23.1.0. The experimental warning would still occur, though. |
@ljharb After upgrading to
|
This comment has been minimized.
This comment has been minimized.
Considering the CLI targets Node.js versions that all support ESM, perhaps the easiest way to mitigate this issue is to start using ES modules instead of CommonJS? Is there any particular blocker that might prevent doing so? |
@jonkoops the issue occurs in |
@ljharb I see you already logged debug-js/debug#975 for that, thanks I'll follow the discussion there. Still, this would presumably also affect the CLI even if this So my question still stands, would there be any technical reason the CLI itself could not be authored in ESM in terms of compatibility? |
Probably not? but there'd also be no concrete benefit, either - only a subjectively ideological one. |
Any update on this about the fix? Cannot build the Laradock because of this bug. During the build stuck on this progress:
|
@planetarquasar those are just log messages, it shouldn't interfere with a build process. you can set |
Where should I put this? |
in your environment - it's an environment variable. Happy to help with further questions, but let's please not continue pinging people by commenting on this issue :-) (npm folks, feel free to hide some of these tangents as off topic) |
For information, this 'WARNING' was make my yoeman installation not working with issue: yeoman/yeoman#1778 putting |
So is this what we should all be doing? Any reason not to? |
Example:
|
Debug was updated but this didn't resolve the issue. See later comments in this issue. |
This is still happening to me. I'll make a new issue |
Confirmed. I use npm version 10.9.0, this issue still appears. Environment:
package.json
|
This should not be a problem in node 22 anymore (ref: debug-js/debug#975 (comment)). |
(it's something npm can work around, by pinning to an older version of |
Is there an existing issue for this?
This issue exists in the latest npm version
Current Behavior
When installing any package with Node.js v23.0.0 and npm v10.9.0, I get the following warning
Expected Behavior
No response
Steps To Reproduce
No response
Environment
The text was updated successfully, but these errors were encountered: