26

I am new to angular and I have been trying to learn more about angular2. I have followed the getting started guide to create the angular2-quickstart project. However when I am running the command npm start, the browser start but everything fails after 1 second. Below is the content of my npm error log file:

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 ]

Can you help me figure out what I am doing wrong ?

Regards

Eric Martinez
  • 31,277
  • 9
  • 92
  • 91
Bakary Diarra
  • 333
  • 1
  • 4
  • 9

9 Answers9

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

Ignatius Andrew
  • 8,012
  • 3
  • 54
  • 54
10

The solution is to add this line in /etc/sysctl.conf

fs.inotify.max_user_watches = 524288 

and type in the console sudo sysctl -p

ssuperczynski
  • 3,190
  • 3
  • 44
  • 61
  • 1
    this solved the issue, thanks. However, a little explanation would be nice: http://linux.die.net/man/8/sysctl and http://unix.stackexchange.com/questions/13751/kernel-inotify-watch-limit-reached were quite instructive – Manube Mar 20 '16 at 13:54
  • How do i do this in Windows 10 ? – shakee93 Jun 18 '16 at 18:27
  • 2
    @Shakee93 .... its time to go linux ... :P .... better now then never =D – Harry Jul 06 '16 at 10:29
5

A lot of people said removing tsc from the package.json start script helped them. In this case the problem is with typescript finding an issue in your code.

Try running tsc from the terminal and see what the output is and fix it. If the issue was with tsc then fixing this should remove the error.

tt_Gantz
  • 2,786
  • 3
  • 23
  • 43
1

I have this problem too. It seems what it is problem with dependences of lite-server.

I changed line in packages.json:

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

This solution helps me to investigate Angular2 further, but will be good to solve problem with lite-server later.

Nick
  • 9,735
  • 7
  • 59
  • 89
0

In my case I just forgot to run

npm install
Raphayol
  • 1,266
  • 11
  • 14
0

I solved it by changing:

"concurrently": "^3.0.0",

to

"concurrently": "^2.0.0",

in package.json

Saibot
  • 21
  • 1
0

In my case one of my TypeScript import statement paths where incorrect.

gwest7
  • 1,556
  • 19
  • 26
0

In Package.json script instead of removing tsc from start section I defined it as below:

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

So the "scripts" now looks like this:

"scripts": {
    ...
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\",
    ...
}
PiotrWolkowski
  • 8,408
  • 6
  • 48
  • 68
0

Solved not being able to start npm start error:

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

(after all the above attempts failed) with: in package.json do: "tsc": "tsc", "tsc:w": "tsc -w", "start": "concurrently \"tsc -w\" \"lite-server\" ",