How can I pass arguments to the executable in nodemon (or node-supervisor)?

Hubro picture Hubro · Jan 15, 2012 · Viewed 13.4k times · Source

node can be run with a debug parameter like this

$ node --debug src/file.js

I can also pass that parameter through the coffee-script binary like this

$ coffee --nodejs --debug src/file.coffee

Which works. But things get more difficult when I involve supervisor. Running coffee scripts is no problem:

$ supervisor -w src src/file.coffee

But I want to debug the coffee scripts that I'm running with supervisor. How can I send arguments such as --debug through supervisor? I tried setting the executable to a string with the arguments like this:

$ supervisor -w src -x "coffee --nodejs --debug" src/server.coffee

Which produced an infinitely repeating error message saying

DEBUG: Starting child process with 'coffee --nodejs --debug src/server.coffee'
DEBUG: execvp(): No such file or directory

Which is odd, because running coffee --nodejs --debug src/server.coffee in the terminal works.

So how can I send arguments through supervisor?


Edit: I want to expand my question with mentioning that I've now tried using nodemon as well. It seems nodemon is considered preferable to node-supervisor, so I'll accept any answer that explains how to pass --debug to the node process when launching coffee scripts through nodemon


Edit: Here's the output from nodemon. Clearly the arguments are not passed in the same order :-(

$ nodemon -w src -x coffee --nodejs --debug src/server.coffee
15 Jan 03:41:56 - [nodemon] v0.6.5
15 Jan 03:41:56 - [nodemon] watching: /foo/bar/server/src
15 Jan 03:41:56 - [nodemon] running --debug
15 Jan 03:41:56 - [nodemon] starting `coffee --debug --nodejs src/server.coffee`

node.js:201
        throw e; // process.nextTick error, or 'error' event on first tick
              ^

Error: unrecognized option: --debug

Answer

Remy Sharp picture Remy Sharp · Jan 16, 2012

actually, it turned out to be a bug :)

The short way:

nodemon --debug -w src src/server.coffee

Or (where --nodejs and --debug are included as the exec)

nodemon -x "coffee --nodejs --debug" -w src src/server.coffee

Or (looks nicer than above)

nodemon -x coffee --nodejs --debug -w src src/server.coffee

(all on nodemon 0.6.6)