Home > Web Front-end > JS Tutorial > body text

Tired of the punycode deprecation message?

WBOY
Release: 2024-08-07 09:06:33
Original
377 people have browsed it

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  
     ...
Copy after login

The "Solve"

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

NODE_NO_WARNINGS=1
Copy after login

For example,
if you previously had

"start": "vite"
Copy after login

change it to

"start": "NODE_NO_WARNINGS=1 vite"
Copy after login

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
Copy after login

or

pnpm dlx punycode-detector
Copy after login


This also works for other tools

For example,
if you previously had

"start": "ember serve"
Copy after login

change it to

"start": "NODE_NO_WARNINGS=1 ember serve"
Copy after login

The above is the detailed content of Tired of the punycode deprecation message?. For more information, please follow other related articles on the PHP Chinese website!

source:dev.to
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template