Angular 2 QuickStart实时服务器错误

时间:2015-12-21 15:46:24

标签: angular

我是棱角分明的新手,我一直在努力了解更多有关angular2的信息。 我按照入门指南创建了angular2-quickstart项目。 但是当我运行命令npm start时,浏览器启动但是1秒后一切都失败了。 以下是我的npm错误日志文件的内容:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'lite' ]
2 info using npm@3.3.12
3 info using node@v5.2.0
4 verbose run-script [ 'prelite', 'lite', 'postlite' ]
5 info lifecycle angular2-quickstart@1.0.0~prelite: angular2-quickstart@1.0.0
6 silly lifecycle angular2-quickstart@1.0.0~prelite: no script for prelite, continuing
7 info lifecycle angular2-quickstart@1.0.0~lite: angular2-quickstart@1.0.0
8 verbose lifecycle angular2-quickstart@1.0.0~lite: unsafe-perm in lifecycle true
9 verbose lifecycle angular2-quickstart@1.0.0~lite: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/home/bakary/angular2-quickstart/node_modules/.bin:/usr/local/lib/node_modules/npm/bin/node-gyp-bin:/home/bakary/angular2-quickstart/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
10 verbose lifecycle angular2-quickstart@1.0.0~lite: CWD: /home/bakary/angular2-quickstart
11 silly lifecycle angular2-quickstart@1.0.0~lite: Args: [ '-c', 'lite-server' ]
12 silly lifecycle angular2-quickstart@1.0.0~lite: Returned: code: 1  signal: null
13 info lifecycle angular2-quickstart@1.0.0~lite: Failed to exec lite script
14 verbose stack Error: angular2-quickstart@1.0.0 lite: `lite-server`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:232:16)
14 verbose stack     at emitTwo (events.js:88:13)
14 verbose stack     at EventEmitter.emit (events.js:173:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14)
14 verbose stack     at emitTwo (events.js:88:13)
14 verbose stack     at ChildProcess.emit (events.js:173:7)
14 verbose stack     at maybeClose (internal/child_process.js:819:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:212:5)
15 verbose pkgid angular2-quickstart@1.0.0
16 verbose cwd /home/bakary/angular2-quickstart
17 error Linux 3.16.0-50-generic
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "lite"
19 error node v5.2.0
20 error npm  v3.3.12
21 error code ELIFECYCLE
22 error angular2-quickstart@1.0.0 lite: `lite-server`
22 error Exit status 1
23 error Failed at the angular2-quickstart@1.0.0 lite script 'lite-server'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the angular2-quickstart package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     lite-server
23 error You can get their info via:
23 error     npm owner ls angular2-quickstart
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

你能帮我弄清楚我做错了吗?

此致

8 个答案:

答案 0 :(得分:59)

Change the Package.json Scripts Settings

"start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\",

to

"start": "concurrently \"npm run tsc:w\" \"npm run lite\" ",

angular 2 has moved from system js to webpack, find the sample app where you guys can get started with angular2 + webpack + Typescript https://github.com/IgnatiusAndrew/angular2-webpack-starter

答案 1 :(得分:10)

解决方案是在more /?

中添加此行
/etc/sysctl.conf

并输入控制台fs.inotify.max_user_watches = 524288

答案 2 :(得分:5)

很多人说从<html> <head> <title>Test</title> <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" integrity="sha384-1q8mTJOASx8j1Au+a5WDVnPi2lkFfwwEAa8hDDdjZlpLegxhjVME1fgjWPGmkzs7" crossorigin="anonymous"> <style type="text/css"> .navbar.navbar-default{ margin-bottom: 0px; } @media (max-width:767px) { .navbar-toggle.pull-left { margin-left: 10px; } } .menu .col-sm-2, .menu .col-xs-2{ padding-right:0px !important; } .menu .col-sm-10, .menu .col-xs-10{ padding-left:0px !important; } .row .well{ height: 105px; margin: 0; text-align: center; } .top_link{ padding: 15px; } </style> </head> <body> <div class="row menu"> <div class="col-sm-2 col-xs-2"> <div class="well"> SITE LOGO </div> </div> <div class="col-sm-10 col-xs-10"> <div class="row"> <div class="col-sm-12 col-xs-12"> <a href="#" class="pull-right top_link">Nav-A-1</a> <a href="#" class="pull-right top_link">Nav-A-2</a> </div> </div> <div class="row"> <div class="col-sm-12 col-xs-12"> <nav class="navbar navbar-default"> <div class="container-fluid"> <!-- Brand and toggle get grouped for better mobile display --> <div class="navbar-header "> <button type="button" class="navbar-toggle collapsed pull-left" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> <span class="sr-only">Toggle navigation</span> <span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span> </button> </div> <!-- Collect the nav links, forms, and other content for toggling --> <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> <ul class="nav navbar-nav"> <li class="active"><a href="#">Nav-B-1<span class="sr-only">(current)</span></a></li> <li><a href="#">Nav-B-2</a></li> <li><a href="#">Nav-B-3</a></li> <li><a href="#">Nav-B-4</a></li> </ul> <ul class="nav navbar-nav navbar-right"> <li><a href="#">Form-Right</a></li> </ul> </div><!-- /.navbar-collapse --> </div><!-- /.container-fluid --> </nav> </div> </div> </div> </div> </body> </html>启动脚本中删除tsc有助于他们。在这种情况下,问题在于打字稿在代码中发现问题。

尝试从终端运行package.json,看看输出是什么并修复它。如果问题出在tsc,则修复此问题应删除错误。

答案 3 :(得分:1)

我也有这个问题。似乎lite-server的依赖性是什么问题。

我更改了packages.json中的行:

"start": "concurrent \"npm run tsc:w\" \"node .\" "

这个解决方案可以帮助我进一步研究Angular2,但稍后会很好地解决lite-server的问题。

答案 4 :(得分:0)

在我的情况下,我只是忘了跑

npm install

答案 5 :(得分:0)

我通过改变来解决它:

&#34;同时&#34;:&#34; ^ 3.0.0&#34;,

&#34;同时&#34;:&#34; ^ 2.0.0&#34;,

package.json中的

答案 6 :(得分:0)

在Package.json脚本中,而不是从tsc部分删除start,我将其定义如下:

"tsc": "tsc",
"tsc:w": "tsc -w",

所以"scripts"现在看起来像这样:

"scripts": {
    ...
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\",
    ...
}

答案 7 :(得分:0)

解决了无法启动npm启动错误:

    tsc && concurrently "tsc -w" "lite-server"

(以上所有尝试失败后):在package.json中执行:         “tsc”:“tsc”,         “tsc:w”:“tsc -w”,         “start”:“并发”tsc -w \“\”lite-server \“”,