Angular 5 - how to keep auto recompiling on file changes even after errors (webpack failed to compile)

Viewed 887

I've just very recently started using Angular5. I've created a project, and use

ng serve

to launch it - which seems to take ages to initially start up for me, easily 5-10 minutes or more. Not sure if this is normal, but maybe in some way related to slow network drives or anything else in the IT environment here.

Anyway, once it has finally launched, things are smooth as it recompiles on the fly upon any changes. But sometimes, for certain mistakes in the source code (eg trying to import a module from an invalid path), compilation seems to fail and ng ends with "webpack: Failed to compile"

If that happens, it seems Angular stops listening to file changes / stops automatically recompiling, and is gone for good - unless I shut down with Ctrl+C and run ng serve again. Which leaves me waiting for 5-10 minutes again...

So, question is: Is this expected behavior? Is there any way to have Angular continue to monitor file changes and recompile automatically, even when one of those more serious errors have happened?

Thanks

1 Answers

I have not come across such an issue, but I was facing some strange compiling issues when trying to run ng serve. Have you tried the following command:

ng update @angular/cli @angular/core

After running this my compiling issues were resolved.

Related