Why am I getting the following warning?
(node:22063) [DEP0040] DeprecationWarning: The
punycode
module is deprecated. Please use a userland alternative instead. (Usenode --trace-deprecation ...
to show where the warning was created)
my OS is Ubuntu 22.04.
The error occurred when I try 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.
As I understand it, the punycode is deprecated, and I need to use userland as an alternative. But I don't know how to use that. I installed the userland module but nothing happens.
Quick Solution for the Punycode Deprecation Warning
If the Node.js version is not critical for your use case, you can resolve the issue with the following steps:
Option 1: Use an earlier Node.js version
Punycode is deprecated in Node.js version 21 and later. To avoid the warning, you can install and use Node.js version 20.5.1 with NVM:
nvm install 20.5.1
nvm use 20.5.1
Option 2: Suppress the deprecation warning
If changing the Node.js version isn’t feasible, you can suppress the deprecation warnings by setting the following environment variable:
export NODE_OPTIONS="--no-deprecation"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With