简体   繁体   English

win7 express js:'express'在cmd中无法识别

[英]win7 express js: 'express' is not recognized in cmd

I have node.js installed and running fine on windows 7 computer. 我安装了node.js并在Windows 7计算机上正常运行。 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 我得到: '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 我在C:\\ Users \\ ME \\ AppData \\ Roaming \\ npm目录中看到'express','express.cmd'和'node_modules'目录以及'express'和'express-generator'文件夹

I added the npm directory to my PATH in case that was missed. 我将npm目录添加到我的PATH中以防错过。

I tried all the solutions I could find: 我尝试了所有可以找到的解决方案:

'Express' is not recognized command (windows) 'Express'无法识别命令(windows)

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

what else can I try to get express working? 还有什么我可以尝试快速工作?

Check that you have the path to the express folder in the path. 检查路径中是否有express文件夹的路径。 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. 请记住,您需要重新打开cmd以应用环境变量中的更改,因为修改它们不会修改当前工作进程的变量AFAIK。 If you are changing system-wide environment variables, you may need to restart Windows. 如果要更改系统范围的环境变量,则可能需要重新启动Windows。

You also may need to check if PATHEXT contains .CMD extension. 您还可能需要检查PATHEXT是否包含.CMD扩展名。

  1. Set Your npm Path variable 设置你的npm Path变量

    c:\\Users\\\\AppData\\Roaming\\npm C:\\ USERS \\\\应用程序数据\\漫游\\ NPM

  2. Restart Your CMD 重新启动您的CMD

以管理员身份运行commad提示符,这种方式express将被安装到system32中,并且可以在commant提示符上进行识别。只需打开命令提示符作为系统管理员然后使用npm install -g express全局npm install -g express ,然后你可以转到任何文件夹并使用express生成您的应用程序

If still its not working re-install the node.js and start express install process again. 如果仍然无法正常工作,请重新安装node.js并再次启动快速安装过程。

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

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'). (如果您运行Windows 8/10,则右键单击cmd图标并选择“以管理员身份运行”)。

I think you need to update node to the latest version then run the 3 commands mentioned earlier and it should work 我认为您需要将节点更新到最新版本然后运行前面提到的3个命令,它应该工作

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

The key is to update node 1st! 关键是更新节点1!

Above answer still did not solve the problem for me. 以上回答仍然没有为我解决问题。 However adding the path of .bin lies fixed it for me. 然而,添加.bin的路径对我来说是固定的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM