1

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.
  • 2
    Are you using nvm as a version manager on Windows? – Khamaseen Feb 06 '23 at 18:55
  • I have the same problem. After using nvm to install node 19.6.0, npm displays the above error message no matter what. Even if I use nvm to go back to another version, and even if I nvm uninstall and nvm install, npm still displays this message. – Moby Disk Feb 09 '23 at 02:15
  • @Khamaseen I got the same problem and I use nvm on windows. any solutions ? – Seif A. Feb 22 '23 at 11:26
  • @SeifA. Reinstall everything. Be sure to only use nvm when installing it again. Also be sure you have no other node version that have been installed without nvm before installing it again. – Khamaseen Feb 22 '23 at 12:33

1 Answers1

0

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.

Moby Disk
  • 3,761
  • 1
  • 19
  • 38