全局安装的Express.JS在Windows上找不到

时间:2014-12-03 12:49:34

标签: node.js express npm

我已尝试通过全局安装express-generator但未找到它。有人可以帮忙吗?

我试过打开一个新的CMD / Powershell,同样的事情发生了。

PS C:\Users\testuser\testme> npm install -g express-generator
npm http GET https://registry.npmjs.org/express-generator
npm http 304 https://registry.npmjs.org/express-generator
npm http GET https://registry.npmjs.org/commander
npm http GET https://registry.npmjs.org/mkdirp
npm http 304 https://registry.npmjs.org/commander
npm http 304 https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/keypress
npm http GET https://registry.npmjs.org/minimist
npm http 304 https://registry.npmjs.org/keypress
npm http 304 https://registry.npmjs.org/minimist
C:\ProgramData\chocolatey\lib\nodejs.commandline.0.10.31\tools\express -> C:\ProgramData\chocolatey\
lib\nodejs.commandline.0.10.31\tools\node_modules\express-generator\bin\express
express-generator@4.9.0 C:\ProgramData\chocolatey\lib\nodejs.commandline.0.10.31\tools\node_modules\
express-generator
├── commander@1.3.2 (keypress@0.1.0)
└── mkdirp@0.5.0 (minimist@0.0.8)
PS C:\Users\testuser\testme> express
express : The term 'express' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the path
is correct and try again.
At line:1 char:1
+ express
+ ~~~~~~~
    + CategoryInfo          : ObjectNotFound: (express:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

PS C:\Users\testuser\testme>

这已在全球范围内安装。

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

检查PATH以确保其中包含全局安装模块的位置。

在命令提示符下:

  1. 输入npm ls -g --depth=0并记下输出第一行上打印的目录
  2. 输入PATH以查看步骤#1中找到的目录是否在路径中...
  3. 如果npmPATH全局安装目录缺失(何时),则添加该目录应该可以解决问题。

    请参阅此其他StackOverflow问题作为参考:Grunt on Windows 8: 'grunt' is not recognized