node.js “http-server”未被识别为内部或外部命令
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24245230/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'http-server' is not recognized as an internal or external command
提问by Liad Livnat
After installing angular-seed project, i did the following steps:
安装 angular-seed 项目后,我执行了以下步骤:
Cloned the repository :
克隆存储库:
git clone https://github.com/angular/angular-seed.git
cd angular-seed
git 克隆https://github.com/angular/angular-seed.git
cd角种子
Then I ran npm install
然后我运行 npm install
at the end of the install i get:
在安装结束时,我得到:
[email protected] prestart C:\Users\user\Documents\GitHub\comilion\angular-seed npm install
[email protected] postinstall C:\Users\user\Documents\GitHub\myproject\angular-seed bower install
[email protected] start C:\Users\user\Documents\GitHub\myproject\angular-seed http-server -a localhost -p 2324
'http-server' is not recognized as an internal or external command, operable program or batch file.
npm ERR! [email protected] start:
http-server -a localhost -p 2324npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the [email protected] start script. npm ERR! This is most likely a problem with the angular-seed package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR!
http-server -a localhost -p 2324 npm ERR! You can get their info via: npm ERR! npm owner ls angular-seed npm ERR! There is likely additional logging output above. npm ERR! System Windows_NT 6.1.7601 npm ERR! command "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "start" 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! code ELIFECYCLE npm ERR! npm ERR! Additional logging details can be found in: npm ERR!
C:\Users\user\Documents\GitHub\myproject\angular-seed\npm-debug.log
[email protected] 预启动 C:\Users\user\Documents\GitHub\comilion\angular-seed npm install
[email protected] postinstall C:\Users\user\Documents\GitHub\myproject\angular-seed bower install
[email protected] start C:\Users\user\Documents\GitHub\myproject\angular-seed http-server -a localhost -p 2324
'http-server' 不是内部或外部命令,也不是可运行的程序或批处理文件。
错误![email protected] 开始:
http-server -a localhost -p 2324npm ERR!退出状态 1 npm ERR!错误![email protected] 启动脚本失败。错误!这很可能是 angular-seed 包 npm ERR 的问题!不是 npm 本身。错误!告诉作者这在你的系统上失败了:npm ERR!
http-server -a localhost -p 2324 npm ERR!您可以通过以下方式获取他们的信息:npm ERR!npm 所有者 ls angular-seed npm ERR!上面可能有额外的日志输出。npm 错误!系统 Windows_NT 6.1.7601 npm ERR!命令 "C:\Program Files\nodejs\\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "start" 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 错误!代码 ELIFECYCLE npm ERR!npm 错误!可以在以下位置找到其他日志记录详细信息:npm ERR!
C:\Users\user\Documents\GitHub\myproject\angular-seed\npm-debug.log
please let me know if you have any suggestions how to solve this issue.
如果您对如何解决此问题有任何建议,请告诉我。
回答by Liad Livnat
@BenFortune found the answer it was
@BenFortune 找到了答案
http-server needs to be installed globally with npm install -g http-server
http-server 需要全局安装 npm install -g http-server
回答by Nithin Baby
If the accepted solution did not work for you. Try the following. This solved the issue in my system.
如果接受的解决方案对您不起作用。请尝试以下操作。这解决了我系统中的问题。
Make sure the locations of both npm and http-server are added in environment variable 'PATH' (Both user variable and System variable).
确保 npm 和 http-server 的位置都添加到环境变量“PATH”(用户变量和系统变量)中。
If it is not present,
如果它不存在,
add C:\Users\username\AppData\Roaming\npmand C:\Users\username\AppData\Roaming\npm\node_modules\http-serverto environment variable 'PATH'
添加C:\Users\username\AppData\Roaming\npm并添加C:\Users\username\AppData\Roaming\npm\node_modules\http-server到环境变量“PATH”
回答by joedavis
npm install -g http-server
Use this command to install http-servermodule into your project. You can verify this in package.json
使用此命令将http-server模块安装到您的项目中。您可以在package.json
回答by Anuruddha Thennakoon
You can fix the issues by doing the following steps,
您可以通过执行以下步骤来解决问题,
- Install http-server globally by
npm install -g http-server - Added 'PATH' in environment variable for system variable. Path will be like this
C:\Users\username\AppData\Roaming\npm
- 通过以下方式全局安装 http-server
npm install -g http-server - 在系统变量的环境变量中添加了“PATH”。路径会是这样
C:\Users\username\AppData\Roaming\npm

