'http-server'不被识别为内部或外部命令

Lia*_*nat 13 node.js npm angularjs angular-seed

安装angular-seed项目后,我执行了以下步骤:

克隆存储库:

git clone https://github.com/angular/angular-seed.git

cd angular-seed

然后我运行了npm install

在安装结束时我得到:

angular-seed@0.0.0 prestart C:\ Users\user\Documents\GitHub\comilion\angular-seed npm install

angular-seed@0.0.0 postinstall C:\ Users\user\Documents\GitHub\myproject\angular-seed bower install

angular-seed@0.0.0 start C:\ Users\user\Documents\GitHub\myproject\angular-seed http-server -a localhost -p 2324

'http-server'不被识别为内部或外部命令,可操作程序或批处理文件.

错误的ERR!angular-seed@0.0.0 start:http-server -a localhost -p 2324 npm ERR!退出状态1 npm ERR!错误的ERR!在angular-seed@0.0.0启动脚本失败.错误的ERR!这很可能是角度种子包的问题,​​npm ERR!不是与npm本身.错误的ERR!告诉作者你的系统失败了:npm ERR!
http-server -a localhost -p 2324 npm ERR!您可以通过以下方式获取他们的信息:npm ERR!npm owner ls angular-seed npm ERR!上面可能有额外的日志记录输出.错误的ERR!系统Windows_NT 6.1.7601 npm ERR!命令"C:\ Program Files文件\ \\的NodeJS node.exe" "C:\ Program Files文件\的NodeJS \node_modules \故宫\ BIN\NPM-cli.js" "开始" NPM ERR!cwd C:\ Users\user\Documents\GitHub\myproject\angular-seed npm ERR!node -v v0.10.22 npm ERR!npm -v 1.3.14 npm ERR!代码ELIFECYCLE npm ERR!错误的ERR!其他日志记录详细信息可在以下位置找到:npm ERR!
C:\用户\用户\文件\ GitHub的\的myproject \角种子\ NPM-的debug.log

如果您对如何解决此问题有任何建议,请告诉我.

Lia*_*nat 49

@BenFortune找到了答案

http-server需要全局安装 npm install -g http-server

  • 这解决了问题,但不必全局安装。请参阅:/sf/answers/2193849941/ (2认同)

Nit*_*aby 18

如果接受的解决方案不适合您.请尝试以下方法.这解决了我系统中的问题.

确保在环境变量"PATH"(用户变量和系统变量)中添加npm和http-server的位置.

如果不存在,

添加C:\Users\username\AppData\Roaming\npmC:\Users\username\AppData\Roaming\npm\node_modules\http-server环境变量'PATH'


Pha*_*inh 8

如果您使用的是 Window 10。然后运行后

npm install -g http-server
Run Code Online (Sandbox Code Playgroud)

遗嘱http-server.cmd可在C:\Users\your-user\AppData\Roaming\npm

然后检查“http-server”在“cmd”中是否工作。
  • 如果它有效,您就不需要看到下面的部分。
  • 如果不行的话。你需要检查Environment Variable
  • 如果您将变量添加到Path(在管理内部)。您需要cmd以管理员身份运行。
  • 如果将变量添加到Path(系统变量内)。您不需要cmd以管理员身份运行。
  • 添加C:\Users\your-user\AppData\Roaming\npm-> OK-> OK-> Re-open the cmd
  • 意志http-server发挥作用