Skip to content

cannot install or use npm #57963

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
AnNguyen-112 opened this issue Apr 21, 2025 · 3 comments
Closed

cannot install or use npm #57963

AnNguyen-112 opened this issue Apr 21, 2025 · 3 comments

Comments

@AnNguyen-112
Copy link

Version

v20.10.0 same thing happen with v22.x

Platform

npm
node:internal/modules/cjs/loader:1215
  throw err;
  ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-prefix.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1212:15)
    at Module._load (node:internal/modules/cjs/loader:1043:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:164:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.19.0
node:internal/modules/cjs/loader:1215
  throw err;
  ^

Error: Cannot find module 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1212:15)
    at Module._load (node:internal/modules/cjs/loader:1043:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:164:12)
    at node:internal/main/run_main_module:28:49 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.19.0

seem like there is a repeat in the module path. I found npm-cli and npm-prefix in ' 'C:\Program Files\nodejs\node_modules\npm\bin\' not
 'C:\Program Files\nodejs\node_modules\npm\bin\node_modules\npm\bin\'
so node_modules\npm\bin had been repeated twice

Subsystem

No response

What steps will reproduce the bug?

i just dowload nodejs then trying to run npm. did put 'C:\Program Files\nodejs' and '\AppData\Roaming\npm' in system path.
I also reinstall many time but not working

How often does it reproduce? Is there a required condition?

install node and it happen

What is the expected behavior? Why is that the expected behavior?

npm working

What do you see instead?

cannot find module (i mentioned above)

Additional information

No response

@AnNguyen-112
Copy link
Author

Fix bug. In System Environment (Edit Environment Variable), there was an unused path 'C:\Program Files\nodejs\node_modules\npm\bin'. Delete it will solve the problem.

@avivkeller
Copy link
Member

avivkeller commented Apr 21, 2025

i just dowload nodejs then trying to run npm

How did you install Node.js? Was it via an official method?


Also see #52682

@AnNguyen-112
Copy link
Author

i just dowload nodejs then trying to run npm

How did you install Node.js? Was it via an official method?
via installer provided by Nodejs, but the problem is solved. There was a path in Environment Variables (system environment" : 'C:\Program Files\nodejs\node_modules\npm\bin'. when i delete this, npm work fine. Maybe this path direct nodejs to the wrong folder
Also see #52682

@ljharb ljharb closed this as completed Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants