In this article I will detail how I setup a debug configuration in webstorm in order to debug hexo. The information contained here can easily be applied to debugging any node app that is executed with a command lined command (hexo generate
) instead of the more standard node index.js
.
The problem
When setting up a node debug configuration in Webstorm you have to specify a file path. Since we are trying to debug hexo generate
, we don’t have any JavaScript file to specify.
The trick
The trick here is to specify the path to the hexo executable located in node_modules/.bin/hexo
.
When adding your configuration, use the following:
Field | Value | Example |
---|---|---|
Node Interpreter | Path to Node | /usr/local/bin/node (on OSX) |
Node Parameters | Node args to specify debug mode | --debug-brk |
Working Directory | Project Directory | path/to/project |
JavaScript File | Path to hexo executable | node_modules/.bin/hexo |
Application Parameters | CLI command args | generate |
Environment Variables | process.env.ENV_VARIABLE | empty |
Once you are done, set up a breakpoint somewhere and hit the debug button.
Thanks to this Stack Overflow Post for pointing me in the right direction.
You can refer to it if you wish to use node-inspector
instead of Webstorm to do your debugging.