I used the node-v8.11.3-x64.msi version. After I install any new module by "npm install XXXX", the folder npm under nodejs\node_modules will disappear(maybe it was replaced by the new module). Then the captioned Error will appear.
If I install any new module by "npm install XXXX -g", the error will not appear.
Are by any chance you running npm install
in the directory where you installed Node.js (or unpacked Node.js archive)?
You shouldn't do that — doing that would override the bundled node_modules
dir (if you have sufficient permissions).
@ChALkeR So how can we overcome this issue?. for every npm install i have to repair the node.js exe ..becuase npm disappears ater each install
@ChALkeR Thanks for your help. It works
With 2 months without activity from the @mxk0sky I consider this resolved. Feel free to reopen if you need further assistance.
I am facing the same issue. It is so frustrating. I am not able to run any npm commands from VS code. I can run npm commands such as npm -v from windows cmd, but not able to run commands such as npm run serve from anywhere in the system. I get the following error:
module.js:540
throw err;
^
Error: Cannot find module 'C:\Program Files\Git\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Function.Module.runMain (module.js:684:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:608:3
Use -g ( at the end) whenever you install a module
Note - First reinstall or repair your node-js software
for ex- npm install express -g
npm install request -g
Most helpful comment
I am facing the same issue. It is so frustrating. I am not able to run any npm commands from VS code. I can run npm commands such as npm -v from windows cmd, but not able to run commands such as npm run serve from anywhere in the system. I get the following error: