-
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 supports-color@9.0.0 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 npm@9.7.1 -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 > my-web-tools@0.0.0 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: node@22.9.0 $ 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: node@22.9.0 $ 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. |
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: