win7 express js: 'express' is not recognized in cmd

[亡魂溺海] 提交于 2020-01-01 10:28:32

问题


I have node.js installed and running fine on windows 7 computer. I run

> npm install -g express
> npm install -g express-generator
> npm install -g express-generator@3

and they all install successfully. But when I go to a new folder and try:

> express myproject

I get: 'express' is not recognized as an internal or external command, operable program or batch file

I see 'express', 'express.cmd', and 'node_modules' directory with 'express' and 'express-generator' folders in the C:\Users\ME\AppData\Roaming\npm directory

I added the npm directory to my PATH in case that was missed.

I tried all the solutions I could find:

'Express' is not recognized command (windows)

https://groups.google.com/forum/#!topic/express-js/Cr92_LC_pUk

what else can I try to get express working?


回答1:


Check that you have the path to the express folder in the path. remember that you need to reopen cmd to apply the changes in the environment variables as modifying them does not modify the variables of the currently working processes, AFAIK. If you are changing system-wide environment variables, you may need to restart Windows.

You also may need to check if PATHEXT contains .CMD extension.




回答2:


  1. Set Your npm Path variable

    c:\Users\\AppData\Roaming\npm

  2. Restart Your CMD




回答3:


Run the commad prompt as Administrator, this way express will be installed in to system32 and can be recongnized on the commant prompt.so just open command prompt as System administrator then install express globally withnpm install -g express you can then go to any folder and generate your apps with express




回答4:


If still its not working re-install the node.js and start express install process again.

npm install -g express
npm install -g express-generator



回答5:


What worked for me was running

npm install -g express
npm install -g express-generator

from the command prompt with Administrator privileges. (If you run windows 8/10 you get this right clicking on cmd icon and choosing 'Run as administrator').




回答6:


I think you need to update node to the latest version then run the 3 commands mentioned earlier and it should work

npm install -g express npm install -g express-generator npm install -g express-generator@3

The key is to update node 1st!




回答7:


Above answer still did not solve the problem for me. However adding the path of .bin lies fixed it for me.



来源:https://stackoverflow.com/questions/24420428/win7-express-js-express-is-not-recognized-in-cmd

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!