npm.cmd closes instantly after few seconds

2019-09-08 15:47发布

问题:

I'm learning nodeJs. I managed to run nodejs commands on cmd and it works fine. Now I want to install express framework and for that in the tutorial I'm following it asks to type sudo install -g express on npm command prompt. So I typed npm in my windows search, and clicked on it. Right after few seconds less than 3 it closes straight away.

I found that npm.cmd exist in nodejs directory where node.exe found. What could be the problem here. If I were to type the above mentioned command in windows cmd, it says sudo is unrecognized program.SO must I use npm cmd?

回答1:

After running cmd.exe , I guess you would have node installed but still run node -v , it should respond with the version meaning it's working. Now if you want to explicitly install express.js you just have to run on, the command prompt itself,

npm install express -g.

Anyways you can follow this link from their official website. Hope it helps. Also sudo is a program for Unix like operating systems, just in case you needed it.



标签: node.js npm