yarn icon indicating copy to clipboard operation
yarn copied to clipboard

"[DEP0040] The `punycode` module is deprecated" with Node.js 21.x (Rev 2)

Open MikeMcC399 opened this issue 2 years ago • 38 comments

  • 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 punycode module 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

MikeMcC399 avatar Nov 16 '23 08:11 MikeMcC399

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.

MikeMcC399 avatar Nov 17 '23 01:11 MikeMcC399

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 avatar Nov 20 '23 01:11 kayac-chang

@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 avatar Nov 20 '23 01:11 MikeMcC399

@MikeMcC399 can you send the output with --trace-deprecation? I'm personally unable to reproduce it on my end.

RDIL avatar Nov 22 '23 22:11 RDIL

@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.

MikeMcC399 avatar Nov 22 '23 22:11 MikeMcC399

(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 avatar Nov 26 '23 11:11 Mahi12333

@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. (/usr/local/lib/node_modules/yarn/lib/cli.js:56536:18) at webpack_require (/usr/local/lib/node_modules/yarn/lib/cli.js:22:30) at Object. (/usr/local/lib/node_modules/yarn/lib/cli.js:71815:18) 📦🐈 Fast, reliable, and secure dependency management. Done in 0.15s. root@str-bot01:/#

ssstheman avatar Nov 27 '23 14:11 ssstheman

I m facing same issue while running mongo, this issue resolved ?

shashi-appgolive avatar Dec 18 '23 13:12 shashi-appgolive

@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

MikeMcC399 avatar Dec 18 '23 13:12 MikeMcC399

@RDIL

Were you now able to reproduce? and if so, is there still an intention to fix the issue in Yarn Classic?

MikeMcC399 avatar Jan 06 '24 13:01 MikeMcC399

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

gurkulplus avatar Jan 09 '24 11:01 gurkulplus

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.

shashi-appgolive avatar Jan 09 '24 12:01 shashi-appgolive

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.

luyanda avatar Jan 10 '24 16:01 luyanda

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 avatar Jan 10 '24 19:01 SeaForeEx

@SeaForeEx

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?

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.

MikeMcC399 avatar Jan 11 '24 10:01 MikeMcC399

Fixed my issue, I was trying to do this in the Front End instead of the Back End, classic amateur move.

SeaForeEx avatar Jan 11 '24 14:01 SeaForeEx

@MikeMcC399 yeah, I was able to reproduce, I have no idea why it's doing that. I'll try to look into it further.

RDIL avatar Jan 11 '24 18:01 RDIL

Update: I spoke with the team, it looks like the cause was already identified and fixed, but has not been released yet.

RDIL avatar Jan 12 '24 01:01 RDIL

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.

dhruvsinghal7494 avatar Jan 15 '24 15:01 dhruvsinghal7494

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 avatar Jan 16 '24 22:01 JJJ

@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 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. (/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.

MikeMcC399 avatar Jan 17 '24 06:01 MikeMcC399

Facing same issue, is there any update on this?

Cuscal-Ashman avatar Jan 22 '24 06:01 Cuscal-Ashman

@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

MikeMcC399 avatar Jan 22 '24 07:01 MikeMcC399

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

MikeMcC399 avatar Jan 23 '24 09:01 MikeMcC399

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 avatar Jan 24 '24 02:01 noxidsoft

@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).

MikeMcC399 avatar Jan 24 '24 05:01 MikeMcC399

I m facing same issue

Component Version
Yarn (Classic) v1.22.19
Node.js: v21.6.1

Hadi90fe avatar Feb 14 '24 06:02 Hadi90fe

Facing the same issue, is there any update on this?

Mohammed-Aljasem avatar Feb 15 '24 19:02 Mohammed-Aljasem

same issue

emreakdas avatar Feb 15 '24 21:02 emreakdas

same here

OzzyCzech avatar Feb 17 '24 16:02 OzzyCzech