skip to Main Content

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

This is the issue.
my OS was ubuntu 22.04.
The problem cames when i am trying to use my database with mongoose.
The punycode can see somewhere in my package-lock.json file. I didn’t use it myself , it’s coming with node.

My node version is v21.0.0 , i downgraded it into v20.9.0 then v18.18.0 still the warning is there.
I installed userland module but nothing happens.

The problem i understand was the punycode is deprecated and need to use userland alternative punycode.js . But i didn’t know how to make it possible.

2

Answers


  1. This is how I solved this Deprecation Warning:

    Here’s a workaround that might help:

    1. Go to your node_modules directory.

    2. Find the tr46 directory.

    3. Open the index.js file in the tr46 directory.

    4. Replace current require line with this line:

      const punycode = require(‘punycode/’);

    But if you re-install npm packages, or update them, this correction will be lost. However, the Warning disappeared.

    PS:
    Just in case, I use node v21.5.0

    Login or Signup to reply.
  2. this problem happen because punycode is deprecated in node version 21 and above…
    downgrade to node version 20

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search