64222

Angular2 Quickstart lite-server crashes

Question:

Good Morning people from the Internet,

<h3>Intro</h3>

While following the <a href="https://angular.io/docs/js/latest/quickstart.html" rel="nofollow">Angular2 Quickstart</a> guide I have experienced many times issues where lite-server would crash just after executing npm start. Crash would look like this in your terminal:

ERR! Linux 3.19.0-51-generic npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "run" "lite" npm ERR! node v5.7.0 npm ERR! npm v3.8.2 npm ERR! code ELIFECYCLE npm ERR! angular2-quickstart@1.0.0 lite: `lite-server` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the angular2-quickstart@1.0.0 lite script 'lite-server'. npm ERR! Make sure you have the latest version of node.js and npm installed. npm ERR! If you do, this is most likely a problem with the angular2-quickstart package, npm ERR! not with npm itself. npm ERR! Tell the author that this fails on your system: npm ERR! lite-server npm ERR! You can get information on how to open an issue for this project with: npm ERR! npm bugs angular2-quickstart npm ERR! Or if that isn't available, you can get their info via: npm ERR! npm owner ls angular2-quickstart npm ERR! There is likely additional logging output above. npm ERR! Please include the following file with any support request: npm ERR! /home/oscar/dev/cw/npm-debug.log <h3>Most common reasons (and solutions)</h3>

Most of the time the reason was one of the two:

<ul><li>lite-server was not shutdown properly. <em>Solution</em>: Killing all npm / node instances and restarting the server with npm start would do the trick.</li> <li>dependencies are not up to date. <em>Solution</em>: simply deleting the node_modules directory, executing npm install to rebuild the dependencies would do the trick.</li> </ul><h3>Other issue</h3>

However when reaching the step called <strong>6.Routing</strong> the issue was a bit different. This time instead of crashing straightaway it was failing after typescript compilation:

16.03.15 16:33:49 200 GET /index.html events.js:154 throw er; // Unhandled 'error' event ^ Error: watch node_modules/angular2/es6/prod/examples/platform/dom/debug/ts/debug_element_view_listener ENOSPC at exports._errnoException (util.js:856:11) ... at FSReqWrap.oncomplete (fs.js:82:15)

Answer1:

I have found the cause of the crash. And I felt like sharing the path so it might help others because there are many forum / stackoverflow threads around the same sort of issue but none solved this crash.

Basically, I looked at the stack trace to find which "module" was failing. Here it is

at FSReqWrap.oncomplete (fs.js:82:15)

and the solution was to execute the following command (see <a href="https://stackoverflow.com/questions/16748737/grunt-watch-error-waiting-fatal-error-watch-enospc" rel="nofollow">this ticket</a>):

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

but instead of just executing it, I needed to understand why setting to 524288 the config item fs.inotify.max_user_watches into /etc/sysctl.conf which is after a system file. I found the answer <a href="https://www.npmjs.com/package/liveload" rel="nofollow">here</a> where it says and I quote:

<blockquote>

Nodejs would report an error if there's too many files for watching due to system limitation, on Linux you can change that by adding fs.inotify.max_user_watches = 524288 to the file etc/sysctl.conf and restart the process

</blockquote>

Hope it helps.

Recommend

  • Combinatios in List of LIsts Prolog
  • os.system not working, but typing the same thing into the command prompt works
  • What are the use cases of dlopen vs standard dynamic linking?
  • Grails eager fetch doesn't retrieve all data
  • How to model a mixture of finite components from different parametric families with JAGS?
  • Safari PHP form submission -file upload hangs
  • Access Google Maps from outside
  • How to extract a number from a string [duplicate]
  • Google Calendar Api is not showing event list
  • Getting IIS6 to play nice with WordPress Pretty Permalinks
  • Titanium doesn't recognize Android SDK on Windows
  • How to get a list with description of all dba packages
  • How to use tag-it
  • ckeditor and jquery UI dialog not working
  • Most efficient way to move table rows from one table to another
  • New Firebase failed: First argument must be a valid firebase URL and the path can't contain “.”
  • JSON encode and decode on PHP
  • Building Qt project for C++11 standard
  • Does Apportable support to build library binary (.a/.so)?
  • using System.Speech.Synthesis with Windows10 universal app (XAML-C#)
  • OSX - always hide certain files
  • Jenkins: FATAL: Could not initialize class hudson.util.ProcessTree$UnixReflection
  • How does document.ready work with angular element directives?
  • Stop Bash Script if Hive Fails
  • Switching to Release Build causes runtime error in Web Reference
  • How to rebase a series of branches?
  • Lost migrations and Azure database is now out of sync
  • Deserializing XML into class C#
  • Why is the timeout on a windows udp receive socket always 500ms longer than set by SO_RCVTIMEO?
  • Function pointer “assignment from incompatible pointer type” only when using vararg ellipsis
  • QuartzCore.framework for Mono Develop
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Buffer size for converting unsigned long to string
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • Hits per day in Google Big Query
  • coudnt use logback because of log4j
  • How to get Windows thread pool to call class member function?
  • python draw pie shapes with colour filled
  • How to Embed XSL into XML