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
This is how I solved this Deprecation Warning:
Here’s a workaround that might help:
Go to your node_modules directory.
Find the tr46 directory.
Open the index.js file in the tr46 directory.
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
this problem happen because punycode is deprecated in node version 21 and above…
downgrade to node version 20