[英]'http-server' is not recognized as an internal or external command
After installing angular-seed project, i did the following steps:安装 angular-seed 项目后,我执行了以下步骤:
Cloned the repository :克隆存储库:
git clone https://github.com/angular/angular-seed.git
git 克隆https://github.com/angular/angular-seed.git
cd angular-seed
cd角种子
Then I ran npm install然后我运行 npm install
at the end of the install i get:在安装结束时,我得到:
angular-seed@0.0.0 prestart C:\\Users\\user\\Documents\\GitHub\\comilion\\angular-seed npm install
angular-seed@0.0.0 预启动 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 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
angular-seed@0.0.0 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.
'http-server' 不是内部或外部命令,也不是可运行的程序或批处理文件。
npm ERR!
npm 错误! angular-seed@0.0.0 start:
http-server -a localhost -p 2324
npm ERR!angular-seed@0.0.0 开始:
http-server -a localhost -p 2324
npm ERR! Exit status 1 npm ERR!退出状态 1 npm ERR! npm ERR!
npm 错误! Failed at the angular-seed@0.0.0 start script.
angular-seed@0.0.0 启动脚本失败。 npm ERR!
npm 错误! This is most likely a problem with the angular-seed package, npm ERR!
这很可能是 angular-seed 包 npm ERR 的问题! not with npm itself.
不是 npm 本身。 npm ERR!
npm 错误! Tell the author that this fails on your system: npm ERR!
告诉作者这在你的系统上失败了:npm ERR!
http-server -a localhost -p 2324 npm ERR!http-server -a localhost -p 2324 npm ERR! You can get their info via: npm ERR!
您可以通过以下方式获取他们的信息:npm ERR! npm owner ls angular-seed npm ERR!
npm 所有者 ls angular-seed npm ERR! There is likely additional logging output above.
上面可能有额外的日志输出。 npm ERR!
npm 错误! System Windows_NT 6.1.7601 npm ERR!
系统 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!
命令 "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!
cwd C:\\Users\\user\\Documents\\GitHub\\myproject\\angular-seed npm ERR! node -v v0.10.22 npm ERR!
node -v v0.10.22 npm ERR! npm -v 1.3.14 npm ERR!
npm -v 1.3.14 npm 错误! code ELIFECYCLE npm ERR!
代码 ELIFECYCLE npm ERR! npm ERR!
npm 错误! Additional logging details can be found in: npm ERR!
可以在以下位置找到其他日志记录详细信息:npm ERR!
C:\\Users\\user\\Documents\\GitHub\\myproject\\angular-seed\\npm-debug.logC:\\Users\\user\\Documents\\GitHub\\myproject\\angular-seed\\npm-debug.log
please let me know if you have any suggestions how to solve this issue.如果您对如何解决此问题有任何建议,请告诉我。
@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
全局npm install -g http-server
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\\npm
and C:\\Users\\username\\AppData\\Roaming\\npm\\node_modules\\http-server
to environment variable 'PATH'将
C:\\Users\\username\\AppData\\Roaming\\npm
和C:\\Users\\username\\AppData\\Roaming\\npm\\node_modules\\http-server
到环境变量 'PATH'
npm install -g http-server
Use this command to install http-server
module into your project.使用此命令将
http-server
模块安装到您的项目中。 You can verify this in package.json
您可以在
package.json
验证这一点
You can fix the issues by doing the following steps,您可以通过执行以下步骤来解决问题,
npm install -g http-server
npm install -g http-server
全局npm install -g http-server
C:\\Users\\username\\AppData\\Roaming\\npm
C:\\Users\\username\\AppData\\Roaming\\npm
If you are using Window 10. Then after run如果您使用的是 Window 10。然后在运行后
npm install -g http-server
The http-server.cmd
will available in C:\\Users\\your-user\\AppData\\Roaming\\npm
http-server.cmd
将在C:\\Users\\your-user\\AppData\\Roaming\\npm
可用
Environment Variable
Environment Variable
Path
(inside admin).Path
(在管理员内部)。 You need to run cmd
as Administrator.cmd
。Path
(inside System variable).Path
(在系统变量内)。 You don't need to run cmd
as Administrator.cmd
。C:\\Users\\your-user\\AppData\\Roaming\\npm
-> OK
-> OK
-> Re-open the cmd
.C:\\Users\\your-user\\AppData\\Roaming\\npm
-> OK
-> OK
-> Re-open the cmd
。http-server
will work http-server
将工作For me all that had to be done after the basic install对我来说,在基本安装后必须完成的所有工作
npm install http-server -g
Is to run as administrator from the project directory this command:是以管理员身份从项目目录运行这个命令:
http-server dist/project-name
1-remove http-server by command 1-通过命令删除http-server
npm uninstall http-server -g
2- install again 2-再次安装
npm install http-server -g
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.