Fixing – Error: Cannot find module ‘C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js’

A very common issue most people face when working with nvm tool is that after a fresh setup of this tool the npm command does not seem to find the npm-cli.js. The reason being that the setup process fail to copy few needed files to the expected location.
Though there is no official fix available for this issue as of now, a work around is available as below:
Existing environment:
- Windows 10 professional x64
- nvm installed path – C:\nvm
Steps
Visit the url – https://nodejs.org/en/download/releases/ and download the source for the node.js version that you are trying to work with.

Extract the zip content and copy the npm folder to “C:\nvm\v8.16.0\node_modules“

once you are done with the above, you can use the npm command without any issue:

Note: You will need to repeat the above steps for each version of node.js that you are intending to use
if you don’t patch the installation as shown above, you will face with the following error:
Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js' at Function.Module._resolveFilename (module.js:547:15) at Function.Module._load (module.js:474:25) at Function.Module.runMain (module.js:693:10) at startup (bootstrap_node.js:188:16) at bootstrap_node.js:609:3 module.js:549 throw err; ^ Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js' at Function.Module._resolveFilename (module.js:547:15) at Function.Module._load (module.js:474:25) at Function.Module.runMain (module.js:693:10) at startup (bootstrap_node.js:188:16) at bootstrap_node.js:609:3