Skip to content

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

Closed
@MikeMcC399

Description

@MikeMcC399

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions