nodejs / help

:sparkles: Need help with Node.js? File an Issue here. :rocket:
1.44k stars 276 forks source link

npm doesn't work in PowerShell, only npm.cmd does #4436

Open OksanaML78 opened 3 days ago

OksanaML78 commented 3 days ago

Node.js Version

v20.15.0

NPM Version

v10.8.0

Operating System

Windows 11 Pro

Subsystem

console, Other

Description

In PowerShell terminal, the npm command doesn't work; only npm.cmd works. However, in Command Prompt, the npm command works. To troubleshoot, I have reinstalled Node.js, PowerShell, checked environment variables, confirmed the path is set correctly, and npm.cmd exists in the nodejs folder.

Minimal Reproduction

No response

Output

No response

Before You Submit

RedYetiDev commented 3 days ago

@anonrig Is this https://github.com/nodejs/node/issues/53538?

hzhang20902 commented 2 days ago

Can you confirm you installed node.js in the powershell environment, and not just cmd prompt (node -v)? Yes I know its weird, but sometimes it just happens. If you have, try running as admin and:

npm install -g npm

with npm.cmd for the first npm.

If that still doesn't work, you will have to go into your PATH environment and manually set 'npm' as a command variable bc if npm.cmd works then you definitely have npm, but for whatever reason the PATH variable never got set or never got set globally, or was removed.

OksanaML78 commented 2 days ago

Thanks for the advice and links, so far manipulating the environment variable has not helped. I will try the advice provided in the links. At the same time, when selecting сmd or git bash, the command npm works in the terminal, the problem is only with the PowerShall

RedYetiDev commented 2 days ago

Thanks for the info! Could you glance over the linked issue and let me know whether they are the same problem? Thanks!

RedYetiDev commented 12 hours ago

Hey @OksanaML78, did you get a chance to test the comment above? If so, how did it go? (What happens with npx commands?)

Also, did @hzhang20902 npm install -g npm work?