我已尝试通过全局安装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>
这已在全球范围内安装。
有什么想法吗?
答案 0 :(得分:2)
检查PATH
以确保其中包含全局安装模块的位置。
在命令提示符下:
npm ls -g --depth=0
并记下输出第一行上打印的目录PATH
以查看步骤#1
中找到的目录是否在路径中... 如果npm
中PATH
全局安装目录缺失(何时),则添加该目录应该可以解决问题。
请参阅此其他StackOverflow问题作为参考:Grunt on Windows 8: 'grunt' is not recognized