Node.JS NPM not working on Windows

2019-05-22 09:42发布

问题:

I just installed the latest version of nodejs, and while I can get it to run js files just fine, I can't get npm to do anything.

If I open the node.exe, it brings up a prompt, then I separately tried each of the following and none of them work:

> node npm install socket.io
> npm install socket.io
> help
> node help

ALL of the above result in nothing but the line "..." to be returned, then every thing I type in after that, I just get another line of "...".

This is extremely frustrating. What am I doing wrong?

回答1:

Opening node.exe will bring up the Read–eval–print loop (REPL). Try just:

c:\users\windowslogin>npm install socket.io


回答2:

If you had command prompt open whilst installing the latest nodejs then the path to npm in windows path will not be recognised until you close the command prompt and open a new one.

I know this already has an accepted answer but I just found this and then realised my own mistake and thought it might help someone else.