I installed nvm for windows (https://github.com/coreybutler/nvm-windows) and switched to an older node version (v8.17.0). Since doing this, npm
no longer works and returns:
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
module.js:550
throw err;
^
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (module.js:548:15)
at Function.Module._load (module.js:475:25)
at Function.Module.runMain (module.js:694:10)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
I checked, and indeed although the folder C:\Program Files\nodejs\node_modules\
exists, it is completely empty. So npm indeed doesn't exist in that folder. where npm
returns:
C:\Program Files\nodejs\npm
C:\Program Files\nodejs\npm.cmd
C:\Users\MyName\AppData\Roaming\npm\npm
C:\Users\MyName\AppData\Roaming\npm\npm.cmd
Here I read to run SET PATH=C:\Program Files\Nodejs;%PATH%
, which I did, but that made no difference (still the same error when running npm).
I've also tried re-installing npm
using the steps here, but after re-installing it, it still gives the above error.
How can I solve this?