Grunt-express server with a contributor

I try to use both grunt-express-server, and grunt-contrib-watch, however, as soon as my express server starts up, it no longer looks at viewing or rebooting. I have installed the server installation 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']);
};
+3
source share
1 answer

I was able to clone your project and was able to get everything by doing the following setup in server.js:

app.listen(3000);

at

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

According to the grunt-express-server Usage docs , your server should console.logoutput so that the grunt task can tell that the server has started successfully.

( , , LiveReload)

delay , - :)

+11

All Articles