1

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 npmreturns:

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?

Marty
  • 2,132
  • 4
  • 21
  • 47
  • 1
    Did you work through [the readme](https://github.com/coreybutler/nvm-windows/blob/master/README.md)? It says to remove any existing npm install in `.../AppData/Roaming` which doesn't seem to have been done and could be a part of the issue. Windows searches the directories in the `PATH` variable from left to right, and if it finds an existing installation that does have NPM it would try to use that because it has no way to know whether it's broken. – l3l_aze Jul 28 '20 at 17:29
  • Thanks, had overlooked that part ;( This indeed fixed it. – Marty Jul 28 '20 at 17:50
  • No problem, just glad you're back on track! :) Nothing worse than being stuck fixing problems outside of a project, lol. – l3l_aze Jul 28 '20 at 18:24

0 Answers0