-->

Make watch not break down on error thrown by grunt

2019-08-14 04:59发布

问题:

I use Yeoman to do some angular development with grunt, livereload etc.

I've also set up a basic node.js/express app and I'm sharing some JS between the client (angular) and the server (node) using grunt-contrib-copy and grunt-express-server that fires on every file-save using watch. So far so good!

The problem is if I introduce a syntax error into the code that I want to share with node and hit save. The syntax error gets shown in the log and breaks/stops the watch. Then I have to go restart the watch in the console by doing $ ctrl+c and $ grunt server.

Is there a way to get grunt-express-server not to break/stop the watch that's going on if a syntax error is found in the js code?

回答1:

I'm the author of grunt-express-server and working the issue here:

https://github.com/ericclemmons/grunt-express-server/issues/27

I've been able to work around this problem by running grunt-parallel or grunt-concurrent, which prevents errors from preventing execution of watch.