npm v9.4.0 is known not to run on Node.js v19.5.0

176 Views Asked by At

I somehow broke npm on my Windows system. Any (literally any) npm command I use gives me the following illogical error:

ERROR: npm v9.4.0 is known not to run on Node.js v19.5.0. You'll need to upgrade to a newer Node.js version in order to use this version of npm. This version of npm supports the following node versions: ^14.17.0 || ^16.13.0 || >=18.0.0. You can find the latest version at https://nodejs.org/.

ERROR: C:\Users\PCName\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\arborist:1 ../../workspaces/arborist SyntaxError: Unexpected token '.' at internalCompileFunction (node:internal/vm:73:18) at wrapSafe (node:internal/modules/cjs/loader:1166:20) at Module._compile (node:internal/modules/cjs/loader:1210:27) at Module._extensions..js (node:internal/modules/cjs/loader:1300:10) at Module.load (node:internal/modules/cjs/loader:1103:32) at Module._load (node:internal/modules/cjs/loader:942:12) at Module.require (node:internal/modules/cjs/loader:1127:19) at require (node:internal/modules/helpers:112:18) at Object.<anonymous> (C:\Users\PCName\AppData\Roaming\npm\node_modules\npm\lib\npm.js:1:18) at Module._compile (node:internal/modules/cjs/loader:1246:14)

  1. I tried uninstalling and re-install node.
  2. I deleted the npm folder in C:\Users\PCName\AppData\Roaming\npm\node_modules, downloaded the latest version here: https://github.com/npm/cli/releases/tag/v9.4.0, extracted it, renamed it to 'npm', and copied it to the folder where I deleted it.
1

There are 1 best solutions below

0
On

I fixed this on my machine by downloading the node installer from https://nodejs.org/en/download/ I did not even bother to uninstall my existing node.

Caveat: After doing this, nvm stopped working. When I do nvm use XXXX it says that it switched versions but it did not.