Node: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js

Created on 10 Jul 2018  Â·  6Comments  Â·  Source: nodejs/node

  • Version:
  • Platform:
  • Subsystem:

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.

npm question windows

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:

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

All 6 comments

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

Was this page helpful?
0 / 5 - 0 ratings

Related issues

loretoparisi picture loretoparisi  Â·  3Comments

dfahlander picture dfahlander  Â·  3Comments

cong88 picture cong88  Â·  3Comments

addaleax picture addaleax  Â·  3Comments

willnwhite picture willnwhite  Â·  3Comments