2015-12-21 57 views
26

我是新來的角,我一直在嘗試瞭解更多有關angular2的信息。 我已按照入門指南創建angular2-quickstart項目。 但是,當我運行命令npm start時,瀏覽器啓動,但所有內容都在1秒後失敗。 下面是我的NPM錯誤日誌文件的內容:Angular 2 QuickStart實時服務器錯誤

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 [email protected] 
3 info using [email protected] 
4 verbose run-script [ 'prelite', 'lite', 'postlite' ] 
5 info lifecycle [email protected]~prelite: [email protected] 
6 silly lifecycle [email protected]~prelite: no script for prelite, continuing 
7 info lifecycle [email protected]~lite: [email protected] 
8 verbose lifecycle [email protected]~lite: unsafe-perm in lifecycle true 
9 verbose lifecycle [email protected]~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 [email protected]~lite: CWD: /home/bakary/angular2-quickstart 
11 silly lifecycle [email protected]~lite: Args: [ '-c', 'lite-server' ] 
12 silly lifecycle [email protected]~lite: Returned: code: 1 signal: null 
13 info lifecycle [email protected]~lite: Failed to exec lite script 
14 verbose stack Error: [email protected] 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 [email protected] 
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 [email protected] lite: `lite-server` 
22 error Exit status 1 
23 error Failed at the [email protected] 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 ] 

你能幫我找出我做錯了嗎?

Regards

+0

我解決了mpn和lite-server的問題[here ](http://stackoverflow.com/questions/34335340/angular2-quickstart-npm-start-is-not-working-correctly) –

+0

你是否以管理員權限運行該命令? –

+0

謝謝@TomekMiszczyk!解決方法是更新ubuntu中的sysctl.conf。 –

回答

1

我也有這個問題。這似乎是什麼問題依賴lite-server

packages.json改線:

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

該解決方案有助於我進一步調查Angular2,但會很好用lite-server後需要解決的問題。

8

的解決方案是增加這一行/etc/sysctl.conf

fs.inotify.max_user_watches = 524288 

和類型在控制檯sudo sysctl -p

+0

這解決了這個問題,謝謝。但是,一些解釋會很好:http://linux.die.net/man/8/sysctl和http://unix.stackexchange.com/questions/13751/kernel-inotify-watch-limit-reached是相當指導性的 – Manube

+0

我如何在Windows 10中執行此操作? – shakee93

+0

謝謝兄弟! – Harry

59

更改的package.json腳本設置

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

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

角2已經從系統JS搬到的WebPack,找到示例應用程序在那裏你們可以開始使用angular2 +的WebPack +打字稿https://github.com/IgnatiusAndrew/angular2-webpack-starter

+0

謝謝,這對我工作。 –

+0

這爲我修好了。 –

+1

這工作正常。但爲什麼我們需要這樣做。 – Tun

5

很多人說,從package.json啓動腳本中刪除tsc幫助他們。在這種情況下,問題是打字稿在代碼中發現問題。

嘗試從終端運行tsc,看看輸出是什麼,解決它。如果問題出在tsc,那麼解決這個問題應該會消除錯誤。

+0

重大事件。這解決了我的問題。 :D謝謝。 – Codemole

0

在我來說,我只是忘了運行

npm install 
0

我解決它通過改變:

「同時」: 「^ 3.0.0」,

「同時「: 」^ 2.0.0「,在的package.json

0

在我的情況下,我的一個TypeScript import聲明路徑不正確。

0

In Package。的JSON腳本,而不是從start部拆卸tsc我如下定義它:

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

所以"scripts"現在看起來是這樣的:

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

解決不能啓動NPM啓動錯誤:

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

(以上所有嘗試均失敗後):in package.json do: 「tsc」:「tsc」, 「tsc:w」:「tsc -w」, 「start」:「concurrently \」tsc -w \「\」lite-server \「」,