2014-12-07 103 views
0

我正在学习AngularJS。为此,我遵循tutorial并检出了示例代码(git clone --depth=14 https://github.com/angular/angular-phonecat.git)。然后,我跑了npm installnpm install -g bower如何诊断“npm start”的失败?

最后,我试图用npm start启动web服务器。

它没有工作,我得到了下面的错误输出:

0 info it worked if it ends with ok 
1 verbose cli [ 'C:\\Program Files\\nodejs\\\\node.exe', 
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js', 
1 verbose cli 'start' ] 
2 info using [email protected] 
3 info using [email protected] 
4 verbose node symlink C:\Program Files\nodejs\\node.exe 
5 verbose run-script [ 'prestart', 'start', 'poststart' ] 
6 info prestart [email protected] 
7 verbose unsafe-perm in lifecycle true 
8 info [email protected] Failed to exec prestart script 
9 error [email protected] prestart: `npm install` 
9 error Exit status 7 
10 error Failed at the [email protected] prestart script. 
10 error This is most likely a problem with the angular-phonecat package, 
10 error not with npm itself. 
10 error Tell the author that this fails on your system: 
10 error  npm install 
10 error You can get their info via: 
10 error  npm owner ls angular-phonecat 
10 error There is likely additional logging output above. 
11 error System Windows_NT 6.1.7601 
12 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start" 
13 error cwd D:\dev\js-learning\angular-phonecat 
14 error node -v v0.10.33 
15 error npm -v 1.4.28 
16 error code ELIFECYCLE 
17 verbose exit [ 1, true ] 

我怎样才能解决呢?

回答

0

只要做到:

npm install 

然后:

npm start 

然后打开浏览器,浏览到:

http://localhost:8000 

然后选择/应用程序,你会被带到:

http://localhost:8000/app/#/phones 

如果你仍然有问题,你可以做以下事情,只是为了让应用程序在没有测试的情况下运行。

npm install express --save 

请将以下代码保存为server.js到根:

var express = require('express'); 
var http = require('http'); 
var app = express();   

app.set('port', process.env.PORT || 8000); 
app.use(express.static(__dirname + '/app')); 

var server = http.createServer(app); 

server.listen(app.get('port'), function() { 
    console.log('Express HTTP server listening on port ' + app.get('port') ) ; 
}); 

然后做:

node server.js 

现在浏览:

http://localhost:8000