"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > Tired of the punycode deprecation message?

Tired of the punycode deprecation message?

Published on 2024-08-26
Browse:646

Tired of the punycode deprecation message?

Are you tired of seeing this?:

[DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
     at node:punycode:3:9
     at BuiltinModule.compileForInternalLoader (node:internal/bootstrap/realm:399:7)
     at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:338:10)
     at loadBuiltinModule (node:internal/modules/helpers:96:7)
     at Module._load (node:internal/modules/cjs/loader:1070:17)
     at TracingChannel.traceSync  
     ...

The "Solve"

Change your start or dev script in package.json to be prefixed with:

NODE_NO_WARNINGS=1

For example,
if you previously had

"start": "vite"

change it to

"start": "NODE_NO_WARNINGS=1 vite"

Now you can enjoy console output with 80,000 less lines of spew.


If you are motivated and have the time, it is beneficial to try to help out packages by either:

  • upgrading them to a version that doesn't trigger the deprecation
  • PR a fix that doesn't trigger the deprecation (uses a userland module, as instructed).

The userland module is here: https://github.com/mathiasbynens/punycode.js

And you can scan all your dependencies for violations (so you don't have to rely on runtime to find every occurrance) with this tool: punycode-detector

npx punycode-detector

or

pnpm dlx punycode-detector


This also works for other tools

For example,
if you previously had

"start": "ember serve"

change it to

"start": "NODE_NO_WARNINGS=1 ember serve"
Release Statement This article is reproduced at: https://dev.to/nullvoxpopuli/tired-of-the-punycode-deprecation-message-40ml?1 If there is any infringement, please contact [email protected] to delete it
Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3