grunt-express-server with contrib-watch

I am trying to use both grunt-express-server and grunt-contrib-watch however, as soon as my express server starts, it no longer seems to do any watching or reloading. I have the server setup to spawn in the background. My project is here: https://github.com/RyanHirsch/firem

Here is my Gruntfile.js

module.exports = function(grunt) {
  require('load-grunt-tasks')(grunt);
  // Project configuration.
  grunt.initConfig({
    watch: {
      options: {
        livereload: true,
      },
      express: {
        files:  [ 'index.html', 'server.js' ],
        tasks:  [ 'express:dev' ],
        options: {
          spawn: false
        }
      }
    },
    express: {
      options: {
        // Override defaults here
      },
      dev: {
        options: {
          script: 'server.js'
        }
      }
    }
  });

  grunt.registerTask('default', ['express:dev','watch']);
};

Answers


I was able to clone your project and able to get everything running with the following tweak in server.js:

app.listen(3000);

into:

app.listen(3000, function() {
  console.log('Server listening on port 3000');
});

According to the grunt-express-server's "Usage" docs, your server should console.log some output so that the grunt task can tell that the server has started successfully.

(This is because starting the server is asynchronous, which can cause a race-condition with LiveReload)

Otherwise, there is a delay option for purists who don't want any output from their application :)


Need Your Help

Remove Registry Keys for Windows Phone 7 Emulator

registry windows-installer windows-phone-7

I am trying to get the updated Windows Phone 7 tools installed, but can't get rid of the old ones. The uninstaller wouldn't run, so I had to try more extreme means. I got everything removed excep...

Program displaying wrong values, what needs to be changed?

vb.net visual-studio-2013

My program to display employee records works fine other than the face that it displays incorrect values when it comes to pay. What needs to be changed?