HowTo launch node --debug grunt server on Windows?

2.1k views Asked by At

Running Windows 8.1 and my environment is working great except I cannot start node in --debug so that node-inspector has something to connect to.

I have a Gruntfile setup with grunt-concurrent that lets me open, grunt-devtools, node-inspector then watch just fine but I can't figure out a workable syntax for getting that running with node in debug. Following is what I'd expect to work but also the error I get when I try. Notice that there is a message indicating that the debug server is listening, but something falls apart from there and fails so it does me no good.

C:\PROJECTS\bManWebService_Hapi>node --debug C:\Users\rainabba\AppData\Roaming\npm\grunt server

debugger listening on port 5858

C:\Users\rainabba\AppData\Roaming\npm\grunt:2
basedir=`dirname "$0"`
        ^
SyntaxError: Unexpected token ILLEGAL
    at Module._compile (module.js:437:25)
    at Object.Module._extensions..js (module.js:467:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Module.runMain (module.js:492:10)
    at process.startup.processNextTick.process._tickCallback (node.js:244:9)
2

There are 2 answers

1
Alex Netkachov On BEST ANSWER

It looks like the file C:\Users\rainabba\AppData\Roaming\npm\grunt is not a JS file but a bash shell script. Look for grunt.cmd in the same folder if you need Windows-compatible version.

And event if you find grunt.cmd - starting it as node grunt.cmd is not a proper way. Most likely the grunt.cmd will start the node so you need to somehow pass the --debug argument to the node, called by the grunt.cmd or just run node exactly as grunt.cmd runs it.

1
Tobias Oberrauch On

tl; tr;

node --debug-brk c:\Users\rainabba\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt taskname

You have to use this executable

  • c:\Users\rainabba\AppData\Roaming\npm\node_modules\grunt-cli\bin\grunt

instead of this

  • c:\Users\rainabba\AppData\Roaming\npm\grunt server