I've seen a few fixes floating around that say just disable all the warnings in node. But this kinda grinds my gears as it just hides all warnings, and you do want to see some of them. Investigate and then do something about it... or not.
The answer on this thread https://stackoverflow.com/a/78757478/3593217 is great, but there were so many different dependencies in my project using punycode i really didn't want to go down this route.
It would be better (at least for my situation) to disable the warning just for this package and at the repo level.
I also don't want to prepend every npm script in my packages.json, i want this work across the current project and all the scripts. So...
You can create a .npmrc
file with the following contents:
node-options="--require ./node-warning-bypass.cjs"
Then create a file at the root of your project (you'll need to use the file ending .cjs due to the require in the node options).
const IGNORED_WARNINGS = [
'punycode',
// Add more packages here as needed
];
process.emitWarning = (warning, ...args) => {
if (IGNORED_WARNINGS.some(pkg => warning?.includes(pkg))) return;
return process.emitWarning.call(this, warning, ...args);
};
This way it only ignores punycode so you will see other issues if they arise. And you also have a tidy list of the things you're ignoring (things that will need to be updated at some point).
I had just been ignoring this error as mildly frustrating, but after some test refactors it was failing our CI and it moved from mildly aggravating to in the crosshairs.