【问题标题】:Express.JS installed globally isn't found on Windows在 Windows 上找不到全局安装的 Express.JS
【发布时间】:2019-06-16 18:32:00
【问题描述】:

我尝试通过 global 安装 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>

这已被全局安装。

有什么想法吗?

【问题讨论】:

  • 请检查 C:\Users\testuser\AppData\Roaming\npm 是否有 express 可执行文件(应该是两个文件)

标签: node.js express npm


【解决方案1】:

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

在命令提示符下:

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

如果(何时)PATH 中缺少 npm 全局安装目录,添加它应该可以解决问题。

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

【讨论】:

  • 很好,正是我需要的。效果很好。谢谢。奇怪的是默认没有添加。
猜你喜欢
  • 1970-01-01
  • 2016-11-08
  • 1970-01-01
  • 2018-03-10
  • 2012-09-17
  • 2017-08-11
  • 1970-01-01
  • 1970-01-01
  • 2016-02-22
相关资源
最近更新 更多