1

I would like to add a task to my Gruntfile in order to start my Express server instead of the default server. I tried to had a task and require("server.js") but I think this isn't the right way to do that: running "grunt mytask" there are no errors but the command return immediately..and the express server isn't listening Thank you for your help !

flea89
  • 21
  • 1
  • 4
  • The answer to this is already posted here: http://stackoverflow.com/questions/11943212/whats-the-purpose-of-gruntjs-server-task – Emlyn Murphy Feb 19 '13 at 21:48
  • Thank you for the answer! I couldn't find by myself this answer.. but just before seeing your suggestion I came out with the same solution, but it didn't seem to me the best way to handle this problem! but now seems to be the right way ! – flea89 Feb 20 '13 at 00:15
  • @EmlynMurphy Could you post a complete answer so that it can be marked as accepted? – Adrian Heine Jul 31 '13 at 18:19

1 Answers1

3

you could use grunt-shell to execute commands in the terminal:

for instance if you have a app.js file that configures your express app you can start it from the command line with 'node app.js'

to configure with grunt shell you'd use something like:

grunt.initConfig({
  shell: {
    launchExpress: {
      options: {
        stdout: true
      },
      command: 'node app.js'
    }
  }
});
thisispete
  • 176
  • 1
  • 9