vip-cli icon indicating copy to clipboard operation
vip-cli copied to clipboard

Node 22.x throws warnings regarding deprecated punycode module

Open mhsdef opened this issue 1 year ago • 4 comments

Expected/Desired Behavior

vip commands without warnings

Actual Behavior

matt@kurosawa ~> vip whoami
(node:59820) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:59822) [DEP0040] DeprecationWarning: The `punycode` module is deprecated. Please use a userland alternative instead.
(Use `node --trace-deprecation ...` to show where the warning was created)

Steps to Reproduce the Problem

  1. Install Node 22.4.1 (or likely any 22.x).
  2. Run any vip command.

(Optional) Additional notes

See: https://nodejs.org/docs/latest-v22.x/api/punycode.html

mhsdef avatar Jul 16 '24 14:07 mhsdef

Spose we technically recommend 18.x (source)... and this seems to be coming out of our deps somewhere.

Still, it'd be nice if we could get smoothness on current LTS.

mhsdef avatar Jul 16 '24 14:07 mhsdef

$ NODE_OPTIONS=--trace-deprecation vip
(node:12972) [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 (node:diagnostics_channel:315:14)
    at wrapModuleLoad (node:internal/modules/cjs/loader:215:24)
    at Module.require (node:internal/modules/cjs/loader:1304:12)
    at require (node:internal/modules/helpers:123:16)
    at Object.<anonymous> (/home/volodymyr/automattic/vip-cli/node_modules/whatwg-url/lib/url-state-machine.js:2:18)
$ npm why whatwg-url
[email protected]
node_modules/whatwg-url
  whatwg-url@"^5.0.0" from [email protected]
  node_modules/node-fetch
    node-fetch@"^2.6.1" from the root project
    node-fetch@"^2.6.7" from @automattic/[email protected]
    node_modules/@automattic/vip-go-preflight-checks
      @automattic/vip-go-preflight-checks@"^2.0.16" from the root project

That is, we need to update node-fetch to 3.x (it is ESM only) or replace it with something else.

sjinks avatar Jul 28 '24 21:07 sjinks

Workaround:

diff --git a/package.json b/package.json
index b0af7608..f2abde99 100644
--- a/package.json
+++ b/package.json
@@ -184,6 +184,9 @@
     "@postman/node-keytar": "~7.9.3"
   },
   "overrides": {
+    "node-fetch@^2.6.1": {
+      "whatwg-url": "^14.0.0"
+    },
     "@lando/compose": {
       "js-yaml": "^4.1.0"
     },

sjinks avatar Jul 28 '24 21:07 sjinks

Fix: https://github.com/Automattic/vip-cli/pull/1965

sjinks avatar Jul 28 '24 22:07 sjinks