Automattic / vip-cli

The VIP CLI
https://docs.wpvip.com/vip-cli/
MIT License
58 stars 16 forks source link

Node 22.x throws warnings regarding deprecated punycode module #1942

Open mhsdef opened 1 month ago

mhsdef commented 1 month ago

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 commented 1 month ago

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.

sjinks commented 1 month ago
$ 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
whatwg-url@5.0.0
node_modules/whatwg-url
  whatwg-url@"^5.0.0" from node-fetch@2.7.0
  node_modules/node-fetch
    node-fetch@"^2.6.1" from the root project
    node-fetch@"^2.6.7" from @automattic/vip-go-preflight-checks@2.0.17
    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 commented 1 month ago

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 commented 1 month ago

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