DEV Community

NullVoxPopuli
NullVoxPopuli

Posted on

23

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  
     ...
Enter fullscreen mode Exit fullscreen mode

The "Solve"

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

NODE_NO_WARNINGS=1
Enter fullscreen mode Exit fullscreen mode

For example,
if you previously had

"start": "vite"
Enter fullscreen mode Exit fullscreen mode

change it to

"start": "NODE_NO_WARNINGS=1 vite"
Enter fullscreen mode Exit fullscreen mode

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
Enter fullscreen mode Exit fullscreen mode

or

pnpm dlx punycode-detector
Enter fullscreen mode Exit fullscreen mode


This also works for other tools

For example,
if you previously had

"start": "ember serve"
Enter fullscreen mode Exit fullscreen mode

change it to

"start": "NODE_NO_WARNINGS=1 ember serve"
Enter fullscreen mode Exit fullscreen mode

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

Top comments (1)

Collapse
 
jonkratz profile image
Jonathan Kratzke

Ha! Thanks so much for this. I've been searching every couple of months for a "temp solution" to this as I can't upgrade certain packages yet, and this is the first time I've found someone who described a way to do it...admittedly, I should have just searched for stopping warnings in the first place, but thank you for combining it with this error.

Hostinger image

Get n8n VPS hosting 3x cheaper than a cloud solution

Get fast, easy, secure n8n VPS hosting from $4.99/mo at Hostinger. Automate any workflow using a pre-installed n8n application and no-code customization.

Start now

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay