How to debug with ActionHero

479 views
Skip to first unread message

Nicolas Michel

unread,
Jul 1, 2013, 3:50:56 AM7/1/13
to action...@googlegroups.com
Hello guys,

I'm currently giving a try to actionHero. I like it but I didn't yet found how to debug the code. I wanted to use node-inspector but when trying to access to the debug web page, it conflits with the actionHero routing and the latter says that the action doesn't exists (of course).

So I wanted to know : what's the best way to debug server code with actionHero?

Best regards,
Nicolas

Evan Tahler

unread,
Jul 2, 2013, 12:50:47 AM7/2/13
to action...@googlegroups.com
Hi!

node-inspector works for me (osx 10.8.4, node v0.10.8).  Here's how I got it working:

- While not yet in NPM, it looks like there is a branch of node-inspector which fixes some stuff that broke in node v0.10.  You can include it with git in your `package.json`

   "dependencies": {
      "actionHero": "6.1.0",
      "node-inspector": "git://github.com/dannycoates/node-inspector.git#update-ui"
    },

Be sure to run actionHero with node's `--debug` flag

  node --debug ./node_modules/.bin/actionHero start

Start up node-inspector (both node-inspector and actionHero have the same default port, so you will need to change one of them)

  ./node_modules/.bin/node-inspector --web-port=1234

That's it! Now you can visit http://0.0.0.0:1234/debug?port=5858 and start debugging.  Remember that the way node-debugger works has you first set a breakpoint in the file view, and then you can use the console to inspect various objects.  IE: I put a breakpoint in the default `actionsView` action in the `run` method:

api.bootTime
1372739939789

api.actions.actions['actionsView'][1.0].description
"I will return an array of all the action accessable to uses of this API"

Nicolas Michel

unread,
Jul 3, 2013, 3:53:39 AM7/3/13
to action...@googlegroups.com
Thank you a lot. I'll try it asap ;)

It would be really nice to see such information on a "debug" category of the WIKI page of action hero ;)
Here : https://github.com/evantahler/actionHero/wiki

Nicolas Michel

unread,
Jul 3, 2013, 3:59:08 AM7/3/13
to action...@googlegroups.com
[Out of topic] : You should also put your new tutorial accessible by a link on the wiki page (I didn't found it until I subscribed myself to the google group).

Evan Tahler

unread,
Jul 3, 2013, 12:13:28 PM7/3/13
to action...@googlegroups.com
Good Call.  
I've added the tutorial to the getting started page [https://github.com/evantahler/actionHero/wiki/Getting-Started] and notes about to debugging to 'development mode and debugging' [https://github.com/evantahler/actionHero/wiki/Development-Mode]

Nicolas Michel

unread,
Jul 4, 2013, 12:52:52 AM7/4/13
to action...@googlegroups.com
Nice. Thank you! :)

Mark Tucker

unread,
Jul 26, 2013, 5:25:36 PM7/26/13
to action...@googlegroups.com
I am running on Windows and can successfully start the tutorial using:

C:\node-dev\actionHero-tutorial>.\node_modules\.bin\actionHero start

But when I try to start it in debug mode with node, I get an error:

C:\node-dev\actionHero-tutorial>node --debug .\node_modules\.bin\actionHero start
debugger listening on port 5858

C:\node-dev\actionHero-tutorial\node_modules\.bin\actionHero:2
basedir=`dirname "$0"`
        ^
SyntaxError: Unexpected token ILLEGAL
    at Module._compile (module.js:439:25)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

Any suggestions?

Mark

Evan Tahler

unread,
Jul 27, 2013, 4:44:45 PM7/27/13
to action...@googlegroups.com
This is a windows-specific problem with the way that NPM generates "links" to deeper binaries within node modules.  

If you take a look at the contents of ./node_modules/.bin, you will notice that on windows, npm generates both the {file} and {file}.cmd versions of the references.  All other OSs can use the {file} versions, hence why I picked those for the readme and docs for actionHero.

Unfortunately, it looks like that the {file}.cmd versions also don't work for me (windows 8 64-bt, node 0.10.15).  The good news is that you really don't need those symbolic files, and you can access the binaries directly.  "node --debug ./node_modules/.bin/actionHero start" becomes "node --debug ./node_modules/actionHero/bin/actionHero start", etc.  This works for me

Sorry I can't be of more help, but I don't know too much about the guts of NPM on windows.
Reply all
Reply to author
Forward
0 new messages