Open agalatan opened 4 weeks ago
Nowadays we publish the package both as punycode
and as punycode.js
— so the simpler solution is to npm install punycode.js
and require('punycode.js')
instead. I’d welcome a README patch that mentions these options!
You can't in 3rd party modules, that are deep inside your node_modules
, that's my point. You have very little control on the require
. And there's plenty of them.
node-fetch
brings whatwg-url
which:
(node:4994) [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:108:7)
at Function.Module._load (node:internal/modules/cjs/loader:1099:17)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at Module.require (node:internal/modules/cjs/loader:1339:12)
at require (node:internal/modules/helpers:135:16)
at Object.<anonymous> (/Users/alingalatan/workspaces/apap/node_modules/node-fetch/node_modules/whatwg-url/lib/url-state-machine.js:2:18)
Say you got rid of node-fetch:
(node:5235) [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:108:7)
at Function.Module._load (node:internal/modules/cjs/loader:1099:17)
at TracingChannel.traceSync (node:diagnostics_channel:315:14)
at wrapModuleLoad (node:internal/modules/cjs/loader:217:24)
at Module.require (node:internal/modules/cjs/loader:1339:12)
at require (node:internal/modules/helpers:135:16)
at Object.<anonymous> (/Users/alingalatan/workspaces/apap/node_modules/tr46/index.js:3:16)
Now it's tr46
It just keeps going. punycode
is present in many node_modules
, some not very maintained.
Seriously good grief, who started this insanity? Getting this deprecation warning removed is near impossible from the amount of usage.
It gets better, some (like the parcel
npm module) are require-ing the punycode
dynamically.
But I think my solution also addresses these cases. But you must inject something via --require/-r
either directly or via NODE_OPTIONS
.
See for example https://stackoverflow.com/questions/68774489/punycode-is-deprecated-in-npm-what-should-i-replace-it-with/78946745
The amount of packages which rely on this is insane. Getting rid of this warning almost brought me to tears
punycode
is deprecated, and a userland solution must be usednode_modules
use nativepunycode
and many are out of our control. It's too many. Especially becausenode-fetch
depends onpunycode
, and even if this itself is now native .... we all know what a chaos is innode_modules
.module-alias
and then add before anything else (node -r
or viaNODE_OPTIONS
):And it works. I recommend adding this in the README. I can do it, if I know you will accept it.