Skip to content
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

"[DEP0040] The punycode module is deprecated" with Node.js 21.x #9005

Closed
MikeMcC399 opened this issue Oct 29, 2023 · 38 comments
Closed

"[DEP0040] The punycode module is deprecated" with Node.js 21.x #9005

MikeMcC399 opened this issue Oct 29, 2023 · 38 comments

Comments

@MikeMcC399
Copy link

MikeMcC399 commented Oct 29, 2023

Many Yarn Classic commands including

yarn info
yarn add
yarn install

provoke a deprecation warning under Node.js current version 21.x.

[DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.

Yarn version

Yarn Classic v1.22.19

Steps to reproduce

For example, with Node.js 21.1.0 installed, execute:

npm install yarn -g
yarn info yarn description

shows

$ npm install yarn -g
changed 1 package in 909ms
$ yarn info yarn description
yarn info v1.22.19
(node:2136) [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 0.23s.

Further debug information is output by:

NODE_OPTIONS='--trace-deprecation' yarn info yarn description

Comments

The History section of DEP0040 in the Node.js documentation shows that Node.js punycode has been deprecated since Node.js v7.0.0 in Oct 2016 and, starting with Node.js v21.0.0, this has been changed to a runtime deprecation (see nodejs/node#47202). The runtime deprecation is what has caused it to now become visible.

Node.js v21.0.0 was released on Oct 17, 2023 as the first release of the 21.x major version, so the issue is quite new. Because Yarn Classic v1 is frozen I don't expect this deprecation to be fixed. I'm just sharing because I was confused the first time I saw it and I mistakenly thought that the package I was installing with yarn add was causing the message, not Yarn Classic itself.

(For completeness I mention https://nodejs.org/dist/latest-v21.x/docs/api/punycode.html in combination with the comment in the https://github.com/mathiasbynens/punycode.js#installation section of the userland module about how to fix.)

I'm not seeing DEP0040 shown by Yarn Modern stable 4.0.1, so migrating to Yarn Modern would be a logical mitigation for the deprecation message caused by Yarn Classic.

@ashfaque9426

This comment was marked as off-topic.

@fungilation

This comment was marked as off-topic.

@MikeMcC399

This comment was marked as off-topic.

@ashfaque9426

This comment was marked as off-topic.

@MikeMcC399

This comment was marked as off-topic.

@ashfaque9426

This comment was marked as off-topic.

@MikeMcC399

This comment was marked as off-topic.

@erikspears
Copy link

I'm also getting this on latest MacOS (sonoma) in Terminal. Admitted n00b to all this, but here is the info asked for just above in case it helps:

% node -v
v21.1.0

% yarn -v
1.22.19

% yarn info yarn description
yarn info v1.22.19
(node:11987) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

@arcanis
Copy link
Member

arcanis commented Nov 7, 2023

I'll make a patch to fix this (but indeed, newer releases don't have this problem and various others, so I suggest try to migrate and letting us know on Discord if you hit a blocker; at the time of this post the latest release is 4.0.1).

@MikeMcC399
Copy link
Author

Hi @arcanis

I'm involved with the GitHub JavaScript action cypress-io/github-action which supports both Yarn Classic and Yarn Modern, so I'm happy that there will be a patch for Yarn Classic.

I fully understand the general advice to migrate though.

Many thanks!

@MateuszSamin
Copy link

I'm also getting this on latest MacOS (sonoma) in Terminal. Admitted n00b to all this, but here is the info asked for just above in case it helps:

% node -v
v21.1.0

% yarn -v
1.22.19

% yarn info yarn description
yarn info v1.22.19
(node:11987) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

@erikspears Try to downgrade node to 20.9.0 version. I had similar problem and this help me

@merceyz
Copy link
Member

merceyz commented Nov 14, 2023

Fixed in #9009

@merceyz merceyz closed this as completed Nov 14, 2023
@MikeMcC399
Copy link
Author

@merceyz

@arcanis
Copy link
Member

arcanis commented Nov 14, 2023

Yes, we're working on that. We don't release 1.x often, so the CI is unfortunately a little unstable - it may take us a day or two to propagate all the archives.

@MikeMcC399
Copy link
Author

@arcanis

Thanks for fixing the deprecation issue and good luck in resolving the publication issues as well!

@MikeMcC399
Copy link
Author

@arcanis

I am still seeing this issue with
Node.js: v21.2.0
Yarn: v1.22.21

$ yarn info yarn description
yarn info v1.22.21
(node:18924) [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 (C:\Users\mikem\AppData\Roaming\npm\node_modules\yarn\lib\v8-compile-cache.js:159:20)
    at Object.<anonymous> (C:\Users\mikem\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:56536:18)
    at __webpack_require__ (C:\Users\mikem\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:22:30)
    at Object.<anonymous> (C:\Users\mikem\AppData\Roaming\npm\node_modules\yarn\lib\cli.js:71815:18)
📦🐈 Fast, reliable, and secure dependency management.
Done in 0.46s.

@MikeMcC399
Copy link
Author

@carlosibm
Copy link

carlosibm commented Nov 26, 2023

I hit this today on Mac OS 14.1.1 (23B81). Thanks for planning the fix .

@Mahi12333
Copy link

(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). How solve this warning.

@testfax

This comment was marked as off-topic.

@Bilal-Bangash

This comment was marked as off-topic.

@EightArmCode

This comment was marked as off-topic.

@Amishkaz
Copy link

Original : bitwarden/clients#6689 (comment)

solution that worked for me:
npm install punycode --save

and then in node_modules go to the directory tr46 > index.js

// Replace this:
const punycode = require('punycode');
// With this:
const punycode = require('punycode/');

basically just add a trailing forward slash

@xthukuh
Copy link

xthukuh commented Dec 18, 2023

Reverting to node version 20.5.1 worked for me. (Incase you're frustrated and looking for a quick solution to get rid of the warning)

Step 1. Install NVM

Windows

winget install CoreyButler.NVMforWindows

Linux

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.7/install.sh | bash

Step 2. NVM install and use node version 20.5.1

nvm install 20.5.1
nvm use 20.5.1

@MikeMcC399
Copy link
Author

@xthukuh

The LTS version according to https://nodejs.org/en is 20.10.0. You might want to consider using this one.

@xthukuh
Copy link

xthukuh commented Dec 19, 2023

@xthukuh

The LTS version according to https://nodejs.org/en is 20.10.0. You might want to consider using this one.

Thank you. I was rushing for a fix. I'll consider this.

@handidev
Copy link

still got same error

@MikeMcC399
Copy link
Author

@handidev

still got same error

@MinavKaria
Copy link

still got same error

just downgrade to 20.10.0
it is depreciated in 21.5.0

In cmd

nvm install 20.10.0

nvm use 20.10.0

Done

@Randomdistro
Copy link

thanks minav that ruined my proj

@MatteoKonradi
Copy link

MatteoKonradi commented Jan 1, 2024

I don't even use punycode in my project and this somehow was installed by pnpm.

serv@hey node-back % sudo pnpm run dev         

> hz@1.0.0 dev /Users/hey/Documents/Code/node-back
> npx nodemon ./main.ts

[nodemon] 3.0.2
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: ts,json
[nodemon] starting `ts-node ./main.ts`
check env mongodb+srv://£££££££££££:$$$$$$$$@cluster-0.qevpnkh.mongodb.net/?retryWrites=true&w=majority

mongodb+srv://ghyvl:nXsvoJ4kiVtrKp6T@cluster-0.qevpnkh.mongodb.net/?retryWrites=true&w=majority
(node:38118) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
Server is on port 3000
^C ELIFECYCLE  Command failed.

@crealityeducation
Copy link

I upgraded Node to 21.5 and now I'm also getting this issue. Any issue if I ignore this warning?

@MikeMcC399
Copy link
Author

@crealityeducation

I upgraded Node to 21.5 and now I'm also getting this issue. Any issue if I ignore this warning?

It's only a warning that it could stop working in some future Node.js version > 21.x, as yet undefined, so you are free to ignore the warning. The deprecation is only saying "please plan ahead".

@crealityeducation
Copy link

Hi Mike, Thanks for confirming. I'll keep checking this space for upgrade. Have a good day.

@traez
Copy link

traez commented Jan 6, 2024

Original : bitwarden/clients#6689 (comment)

solution that worked for me: npm install punycode --save

and then in node_modules go to the directory tr46 > index.js

// Replace this: const punycode = require('punycode'); // With this: const punycode = require('punycode/');

basically just add a trailing forward slash

Thanks for this. Good to know there is a workaround.
But knowing it's an insignificant issue, which will go away with future releases, seems I'll just manage it for now.

My specific error response by the way is stated below. I currently get it on every single node.js project I create.

(node:1692) [DEP0040] DeprecationWarning: The punycode module is deprecated. Please use a userland alternative instead.
(Use node --trace-deprecation ... to show where the warning was created)

@shahjalal-bu
Copy link

Remove node.js and install node.js LTS version. It will fix the issue.
https://nodejs.org/en/download/

@MariuzM
Copy link

MariuzM commented Jan 13, 2024

v21.5.0 still has this message

@MikeMcC399
Copy link
Author

@MariuzM

v21.5.0 still has this message

@yarnpkg yarnpkg locked as resolved and limited conversation to collaborators Jan 13, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests