0

Well, I installed a outdated package and I...broke npm. Error:

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

Error: Cannot find module 'C:\Users\nguye\AppData\Local\nodejs\node_modules\npm\bin\npm-cli.js'
←[90m    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)←[39m
←[90m    at Function.Module._load (node:internal/modules/cjs/loader:804:27)←[39m
←[90m    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)←[39m
←[90m    at node:internal/main/run_main_module:17:47←[39m {
  code: ←[32m'MODULE_NOT_FOUND'←[39m,
  requireStack: []

And when I try to fix it, then this happened: (I use Node.js 16.17.0 LTS)

>npm i npm-cli --save
node:internal/modules/cjs/loader:959
  throw err;
  ^

Error: Cannot find module 'C:\Users\nguye\AppData\Local\nodejs\node_modules\npm\bin\npm-cli.js'
←[90m    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:956:15)←[39m
←[90m    at Function.Module._load (node:internal/modules/cjs/loader:804:27)←[39m
←[90m    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)←[39m
←[90m    at node:internal/main/run_main_module:17:47←[39m {
  code: ←[32m'MODULE_NOT_FOUND'←[39m,
  requireStack: []
}

2 Answers 2

1

Uninstall node and npm, and reinstall. This will probably set the paths correctly in your system.

Sign up to request clarification or add additional context in comments.

Comments

1
  1. Delete the node_modules directory
  2. Delete the package-lock.json file
  3. Run npm install
  4. Run npm start or npm run dev

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.