Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I resolve cannot find module npm-cli.js error?

Tags:

node.js

npm

My npm has worked well, however today it shows an error saying,

Error: Cannot find module 'C:\Users\mrsim\node_modules\npm\bin\npm-cli.js'

My npm worked well just an hour ago. I typed "npm start" inside of VSCode to start my react-app and it worked very well!

This nightmare started when I created server folder and typed "npm install express".

Normally when I typed "npm install express" in the terminal, it automatically created node-modules folder and package.json for me without any problem, but none of these appear.

To solve this problem I repair node first, and didn't worked.

Next I changed my environment variable, and didn't worked.

Next I used "SET PATH=C:\Program Files\Nodejs;%PATH%" this sentence in the terminal, and didn't worked.

node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'C:\Users\mrsim\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'C:\Users\mrsim\node_modules\npm\bin\npm-cli.js'
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

This is error message appear on terminal. If i go to that directory, i cannot find npm.cli.js

What should I do...?

like image 892
MINN Avatar asked Sep 15 '25 12:09

MINN


1 Answers

  1. Go to the path that have Appdata\local or Appdata\roaming
  2. Delete the npm and npm cache folder in both
  3. Get back in terminal, Run npm install again, will see a new path ex: npm notice
  4. Run npm install -g [email protected] to update!
  5. Install the new path and ready to go

This solved my problems.

like image 117
Terogene Claudio Avatar answered Sep 17 '25 02:09

Terogene Claudio