"[DEP0040] The `punycode` module is deprecated" with Node.js 21.x (Rev 2)
- re-open of issue #9005 (re-opened as new issue, since a new version of Yarn is involved)
Description
yarn info
provokes a deprecation warning under Node.js current version 21.x.
[DEP0040] DeprecationWarning: The
punycodemodule is deprecated. Please use a userland alternative instead.
Versions
| Component | Version |
|---|---|
| Yarn (Classic) | v1.22.21 |
| Node.js: | ~~v21.2.0~~ v21.6.2 |
Steps to reproduce
With Node.js ~~v21.2.0~~ v21.6.2 installed, execute:
npm install yarn@latest -g
yarn info yarn description
shows
$ npm install yarn -g
changed 1 package in 909ms
$ yarn info yarn description
yarn info v1.22.21
(node:19052) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
📦🐈 Fast, reliable, and secure dependency management.
Done in 1.06s.
Further debug information is output by:
NODE_OPTIONS='--trace-deprecation' yarn info yarn description
The issue is also reproducible with yarn add
npm install [email protected] -g
mkdir yarn-test
cd yarn-test
yarn init -y
yarn add yarn
displays:
yarn add v1.22.1
info No lockfile found.
[1/4] Resolving packages...
⠁ (node:15052) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
info Direct dependencies
└─ [email protected]
info All dependencies
└─ [email protected]
Done in 0.44s.
I also encountered this issue, leave the version here for reference.
| Component | Version |
|---|---|
| Yarn (Classic) | v1.22.19 |
| Node.js: | v21.2.0 |
@kayac-chang
Yarn (Classic) v1.22.19 has already been replaced by v1.22.21, so any attention should be focussed on this latest version.
@MikeMcC399 can you send the output with --trace-deprecation? I'm personally unable to reproduce it on my end.
@RDIL
The following is from WSL2 under Windows 11 with a virtual Ubuntu 22.04.3 environment and nvm as Node manager installed:
npm install yarn@latest -g
yarn -v
1.22.21
export NODE_OPTIONS='--trace-deprecation'
yarn info yarn description
yarn info v1.22.21
(node:2652) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
at node:punycode:3:9
at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:392:7)
at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:328:10)
at loadBuiltinModule (node:internal/modules/helpers:101:7)
at Module._load (node:internal/modules/cjs/loader:1001:17)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (/home/mike/.nvm/versions/node/v21.2.0/lib/node_modules/yarn/lib/v8-compile-cache.js:159:20)
at Object.<anonymous> (/home/mike/.nvm/versions/node/v21.2.0/lib/node_modules/yarn/lib/cli.js:56536:18)
at __webpack_require__ (/home/mike/.nvm/versions/node/v21.2.0/lib/node_modules/yarn/lib/cli.js:22:30)
at Object.<anonymous> (/home/mike/.nvm/versions/node/v21.2.0/lib/node_modules/yarn/lib/cli.js:71815:18)
📦🐈 Fast, reliable, and secure dependency management.
Done in 0.30s.
(node:15108) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.
(Use node --trace-deprecation ... to show where the warning was created) . solve this isseu.
@Mahi12333 Mahi12333 can you help me with some problem?
root@str-bot01:/# NODE_OPTIONS='--trace-deprecation' yarn info yarn description
yarn info v1.22.21
(node:1975) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.
at node:punycode:3:9
at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:392:7)
at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:328:10)
at loadBuiltinModule (node:internal/modules/helpers:101:7)
at Module._load (node:internal/modules/cjs/loader:1001:17)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (/usr/local/lib/node_modules/yarn/lib/v8-compile-cache.js:159:20)
at Object.
I m facing same issue while running mongo, this issue resolved ?
@shashi-appgolive
I m facing same issue while running mongo, this issue resolved ?
If you are having a problem with mongo then you should probably be referring to their support system https://github.com/mongodb/mongo
@RDIL
Were you now able to reproduce? and if so, is there still an intention to fix the issue in Yarn Classic?
I m facing same issue while running mongo, this issue resolved ?
Hi @shashi-appgolive is your issues resolved ? I am also getting this on node 19.9.0 version and mongo 7
I m facing same issue while running mongo, this issue resolved ?
Hi @shashi-appgolive is your issues resolved ? I am also getting this on node 19.9.0 version and mongo 7
Nope! Using local docker with mongo image.
Is there solution to this issue because I can't find one:
(node:9272) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.
I don't wan to reproduce it I need to solve it.
I'm seeing that the way to fix this punycode/userland issue in Node is to change const punycode = require('punycode'); to const punycode = require('punycode/');. I have searched my VSCode file and don't even have the original const punycode anywhere in my project. Where would I add this line of code?
@SeaForeEx
I'm seeing that the way to fix this punycode/userland issue in Node is to change
const punycode = require('punycode');toconst punycode = require('punycode/');. I have searched my VSCode file and don't even have the originalconst punycodeanywhere in my project. Where would I add this line of code?
If you don't have the problem directly in your own code, then the problem would be coming from a module you're using. This issue is about the deprecation caused by Yarn Classic itself. I don't believe that it is possible to patch Yarn as a workaround.
You should be able to see which module(s) have a deprecation issue if you execute:
export NODE_OPTIONS='--trace-deprecation'
yarn
If the deprecation is coming from somewhere else rather than Yarn, then you might be able to patch it. That would however be a subject for the module with the issue.
Fixed my issue, I was trying to do this in the Front End instead of the Back End, classic amateur move.
@MikeMcC399 yeah, I was able to reproduce, I have no idea why it's doing that. I'll try to look into it further.
Update: I spoke with the team, it looks like the cause was already identified and fixed, but has not been released yet.
Fixed my issue, I was trying to do this in the Front End instead of the Back End, classic amateur move.
Hi, how you fixed this issue, mine is still not fixed, showing this error in my every project.
Also still seeing this.
Here's my deprecation output:
→ rm -rf node_modules yarn.lock
took 4s
→ yarn cache clean
success Cleared cache.
✨ Done in 6.47s.
→ node -v
v20.11.0
→ nvm use 21
→ export NODE_OPTIONS='--trace-deprecation'
→ yarn install
yarn install v1.22.21
info No lockfile found.
[1/4] 🔍 Resolving packages...
⠁ (node:51023) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
at node:punycode:3:9
at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:397:7)
at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:333:10)
at loadBuiltinModule (node:internal/modules/helpers:101:7)
at Module._load (node:internal/modules/cjs/loader:1006:17)
at Module.require (node:internal/modules/cjs/loader:1237:19)
at require (/opt/homebrew/Cellar/yarn/1.22.21/libexec/lib/v8-compile-cache.js:159:20)
at Object.<anonymous> (/opt/homebrew/Cellar/yarn/1.22.21/libexec/lib/cli.js:56536:18)
at __webpack_require__ (/opt/homebrew/Cellar/yarn/1.22.21/libexec/lib/cli.js:22:30)
at Object.<anonymous> (/opt/homebrew/Cellar/yarn/1.22.21/libexec/lib/cli.js:71815:18)
warning @ava/babel > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-nullish-coalescing-operator instead.
warning @ava/babel > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-dynamic-import instead.
warning @ava/babel > @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning @ava/babel > empower-core > [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning @ava/babel > babel-plugin-espower > [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning @ava/babel > babel-plugin-espower > call-matcher > [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning @ava/babel > babel-plugin-espower > espurify > [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-class-properties instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-numeric-separator instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-object-rest-spread instead.
warning @babel/[email protected]: This proposal has been merged to the ECMAScript standard and thus this plugin is no longer maintained. Please use @babel/plugin-transform-optional-chaining instead.
warning @electron/rebuild > node-gyp > make-fetch-happen > cacache > @npmcli/[email protected]: This functionality has been moved to @npmcli/fs
[2/4] 🚚 Fetching packages...
error @ava/[email protected]: The engine "node" is incompatible with this module. Expected version "^14.19 || ^16.15 || ^18 || ^20". Got "21.6.0"
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
took 45s 🆗
@JJJ
Also still seeing this.
That is to be expected, since this issue is still open. It was however great to read https://github.com/yarnpkg/yarn/issues/9013#issuecomment-1888289602 which said:
Update: I spoke with the team, it looks like the cause was already identified and fixed, but has not been released yet.
so that leads me to believe that if we wait, then the fix will be released in a new patch of Yarn > v1.22.21.
Here's my deprecation output: ⠁ (node:51023) [DEP0040] DeprecationWarning: The
punycodemodule is deprecated. Please use a userland alternative instead. at node:punycode:3:9 at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:397:7) at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:333:10) at loadBuiltinModule (node:internal/modules/helpers:101:7) at Module._load (node:internal/modules/cjs/loader:1006:17) at Module.require (node:internal/modules/cjs/loader:1237:19) at require (/opt/homebrew/Cellar/yarn/1.22.21/libexec/lib/v8-compile-cache.js:159:20) at Object.(/opt/homebrew/Cellar/yarn/1.22.21/libexec/lib/cli.js:56536:18) at webpack_require (/opt/homebrew/Cellar/yarn/1.22.21/libexec/lib/cli.js:22:30) at Object. (/opt/homebrew/Cellar/yarn/1.22.21/libexec/lib/cli.js:71815:18)
This is basically the same stack trace as I posted in https://github.com/yarnpkg/yarn/issues/9013#issuecomment-1823602528.
You then have warnings concerning @ava/babel which you would need to research in their repo. The same for the other similar warnings.
error @ava/[email protected]: The engine "node" is incompatible with this module. Expected version "^14.19 || ^16.15 || ^18 || ^20". Got "21.6.0" error Found incompatible module.
This error from @ava/typescript says that it is not compatible with Node.js 21. It may prevent your migration to Node.js 21, however this is not a problem that Yarn can help you with.
Facing same issue, is there any update on this?
@basiq-ash
Facing same issue, is there any update on this?
The last update is from last week. See https://github.com/yarnpkg/yarn/issues/9013#issuecomment-1888289602
The issue is also reproducible if Yarn Classic is used to set the version to Yarn Modern:
nvm use 21
corepack disable
npm install yarn -g
yarn set version stable
$ yarn set version stable
(node:30812) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
➤ YN0000: Retrieving https://repo.yarnpkg.com/4.0.2/packages/yarnpkg-cli/bin/yarn.js
➤ YN0000: Saving the new release in .yarn/releases/yarn-4.0.2.cjs
➤ YN0000: Done in 0s 615ms
The issue is reproducible using npm run serve.
I'm on: OS: Ubuntu 20.04.6 LTS on Windows 10 x86_64 Kernel: 5.15.133.1-microsoft-standard-WSL2
npm --version 10.3.0
node --version v21.6.1
(node:47931) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead. (Use `node --trace-deprecation ...` to show where the warning was created) ERROR TypeError: Function.prototype.apply was called on undefined, which is a undefined and not a function
I am not using a reference in my code.
@noxidsoft
npm run serve
- You can follow issue https://github.com/vercel/serve/issues/789 for the problem you describe.
Your comment is in the wrong repository, since this issue is about Yarn, not npm, and the problem with the npm module serve is caused by one of its dependencies. It is not caused by Yarn (which you are not using).
I m facing same issue
| Component | Version |
|---|---|
| Yarn (Classic) | v1.22.19 |
| Node.js: | v21.6.1 |
Facing the same issue, is there any update on this?
same issue
same here