Search code examples
node.jsphpstorm

Debugging a command line NodeJS script in phpStorm 7


I have a NodeJS script that is designed for executing on the command line, ala a shell script.

I want to debug my script in phpStorm 7 however the debugger just sits there and doesn't debug my script.

Script:

#!/usr/bin/env node

var fs = require("fs");

....

phpStorm debug console output:

/opt/local/bin/node --debug-brk=51096 main.js
debugger listening on port 51096

Reading http://www.jetbrains.com/phpstorm/webhelp/running-and-debugging-node-js.html it appears as if the NodeJS plugin is biased towards web applications since most of the instructions contain a line like

copy the URL address at which the application is running.

Which doesn't make sense in this context.

I can run the script via the NodeJS Run Configuration, but I can't debug.

Is there something I'm doing wrong, or is this a fault of the plugin?

UPDATE:

To answer lena's questions:

  • OS is OSX Snow Leopard
  • Java version is 1.6.0_51
  • NodeJS version is v0.10.19
  • IDE build is phpStorm 7 build 131.374
  • NodeJS plugin version 131.488

I had a look at the link lena mentioned and I do have a similar issue, in that the debugger is started but not the app (see console log output above). The issue was fixed for that user in WebStorm 7.0.1 Perhaps this issue will be fixed in a point release of phpStorm if the fixes are merged into the codebase.

Finally, I'm aware that the mention of the browser in the phpStorm web help is a red herring, perhaps the documentation should be updated to accommodate the running/debugging of NodeJS scripts that don't have a web component.


Solution

  • My PhpStorm7 with Mac(Marverick) also have same problem that node.js debugger don't start app. and ,restarting debugger cause IDE fatal error as below.

    com.intellij.javascript.debugger.impl.JSDebugProcess.getBrowserName()Ljava/lang/String;: com.intellij.javascript.debugger.impl.JSDebugProcess.getBrowserName()Ljava/lang/String;
    java.lang.AbstractMethodError: com.intellij.javascript.debugger.impl.JSDebugProcess.getBrowserName()Ljava/lang/String;
        at com.intellij.javascript.debugger.scripts.ScriptManager.getBrowserName(ScriptManager.java:52)
        at com.intellij.javascript.debugger.scripts.RootScriptsNode.buildChildren(RootScriptsNode.java:24)
        at com.intellij.ui.treeStructure.CachingSimpleNode.getChildren(CachingSimpleNode.java:36)
        at 
    

    This fatal error make bug report window pop up,but 'Report to JetBrains' button not enabled,I typed report though, so I could not report this issue to JetBrains.

    I installed PhpStorm7 to debian linux,but same debugger issue occured.

    now I have installed Early Access Program PhpStorm 7.1.

    http://confluence.jetbrains.com/display/PhpStorm/PhpStorm+Early+Access+Program

    It works!!,break points,step execution etc are no problem.