Q: How to fix: "DeprecationWarning: `punycode` module is deprecated."
byteofsoren opened this issue · comments
Kind of Issue
Runtime - command-line tools
Tool or Library
cspell
Version
6.31.1
Supporting Library
Not sure
OS
Linux
OS Version
Archlinux
Description
Hi.
I just wanted to test cspell on a markdown file but i got this report.
$ cspell --locale=sv your_test_file.md
(node:294824) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
CSpell: Files checked: 0, Issues found: 0 in 0 files
I tested the node trace option like below:
$ node --trace-deprecation /usr/bin/cspell --locale=en your_test_file.md
(node:297520) [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:397:7)
at BuiltinModule.compileForPublicLoader (node:internal/bootstrap/realm:333:10)
at loadBuiltinModule (node:internal/modules/helpers:101:7)
at Module._load (node:internal/modules/cjs/loader:1001:17)
at Module.require (node:internal/modules/cjs/loader:1235:19)
at require (node:internal/modules/helpers:176:18)
at Object.<anonymous> (/usr/lib/node_modules/cspell/node_modules/whatwg-url/lib/url-state-machine.js:2:18)
at Module._compile (node:internal/modules/cjs/loader:1376:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
CSpell: Files checked: 0, Issues found: 0 in 0 files
Is that some thing known or did I do something wrong?
Best regards.
/Magnus Sörensen
Steps to Reproduce
$ cspell --locale=sv your_test_file.md
$ node --trace-deprecation /usr/bin/cspell --locale=en your_test_file.md
Expected Behavior
Expected to get a warning of a spelling error or something like that.
Additional Information
No response
cspell.json
No response
cspell.config.yaml
No response
Example Repository
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
The warning is coming from NodeJS v21. Searching for: DeprecationWarning: The punycode
module is deprecated - Google Search shows this issue popping up for a lot of tools.
Even though CSpell does not use punycode directly, it gets imported through cspell -> node-fetch -> whatwg-url -> tr46 -> punycode
There are a few options:
- Update to CSpell v8, the warning will go away since it doesn't use
node-fetch
. - Use Node version less than v21
- Use a patch utility (like patch-package - npm) to change
tr46
as described in node.js - punycode is deprecated in npm - what should I replace it with? - Stack OverflowThen in node_modules go to the directory tr46 > index.js
// Replace this: const punycode = require('punycode'); // With this: const punycode = require('punycode/');
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.