我尝试通过全局安装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
[email protected] C:\ProgramData\chocolatey\lib\nodejs.commandline.0.10.31\tools\node_modules\
express-generator
├── [email protected] ([email protected])
└── [email protected] ([email protected])
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>


该文件已全局安装。

有任何想法吗?

最佳答案

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

在命令提示符下:


键入npm ls -g --depth=0并注意输出第一行上打印的目录
键入PATH以查看在步骤#1中找到的目录是否在路径中...


如果您的npm缺少PATH全局安装目录,则添加它应该可以解决此问题。

请参阅另一个StackOverflow问题作为参考:Grunt on Windows 8: 'grunt' is not recognized

10-01 13:00