如何诊断" npm start"?

时间:2014-12-07 12:40:22

标签: angularjs node.js npm

我正在学习AngularJS。为此,我按照tutorial检查了示例代码(git clone --depth=14 https://github.com/angular/angular-phonecat.git)。

然后,我运行了npm installnpm install -g bower

最后,我尝试使用npm start启动网络服务器。

它没有用,我得到了以下错误输出:

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 npm@1.4.28
3 info using node@v0.10.33
4 verbose node symlink C:\Program Files\nodejs\\node.exe
5 verbose run-script [ 'prestart', 'start', 'poststart' ]
6 info prestart angular-phonecat@0.0.0
7 verbose unsafe-perm in lifecycle true
8 info angular-phonecat@0.0.0 Failed to exec prestart script
9 error angular-phonecat@0.0.0 prestart: `npm install`
9 error Exit status 7
10 error Failed at the angular-phonecat@0.0.0 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 ]

我该如何解决?

1 个答案:

答案 0 :(得分:0)

只是做:

npm install

然后:

npm start

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

http://localhost:8000

然后选择/ app,您将被带到:

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

如果您仍然遇到问题,可以执行以下操作,只是为了让应用程序在没有测试的情况下运行。

npm install express --save

将以下代码作为server.js保存到root:

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