node.jsangularnpmyarnpkgpunycode

punycode is deprecated in npm - what should I replace it with?


I'm using the npm module punycode in my Angular project. VsCode tells me it's deprecated and https://nodejs.org/api/punycode.html#punycode_punycode confirms:

The version of the punycode module bundled in Node.js is being deprecated. In a future major version of Node.js this module will be removed. Users currently depending on the punycode module should switch to using the userland-provided Punycode.js module instead.

The suggestion is to switch to the 'userland-provided' module. What is that?

There is a link to https://github.com/mathiasbynens/punycode.js and I tried including that in my package.json instead of 'punycode' and I get the same error.


Solution

  • Recently I faced this same issue.

    I highly recommend you use the LTS(long term support) version of the node.

    You can validate the version here: https://nodejs.org/en

    when I'm writing this answer the node LTS version is 20.10.0

    so then in your command line you should perform:

    $nvm install 20.10.0
    $nvm use 20.10.0
    

    This solves the problem, because makes you use the most tested and approved version.

    If I use the version with latest features (actually 21.5.0) I will face the problem reported here. There is an issue open in github to solve it by the way.

    You can see more details here: https://github.com/yarnpkg/yarn/issues/9005