Node.js remote debug is the perfect option for the cases, when you project is run inside the Vagrant box.
Luckly, both node.js and WebStorm have all the needed options, to make the debug still possible and convenient.
Below it’s described how to configure the Node.js Remote Debug in WebStorm.
My WebStorm version is 11, node.js version is 4.2.2.
Let’s assume, that my Vagrant box configured to be in private network with my machine, and it exposes all the ports to the IP 192.168.33.10.
node.js remote debug with WebStorm example
- Our node.js app is a simple hapijs server.
- Being inside the Vagrant server we should run the app with the next command:
Shell123node --debug index.js# or, in case you want to use different portnode --debug=5858 index.js
In the console we will see the next:
- Next, let’s configure the WebStorm part. We should create new run/debug configuration for our project.
In case of remote debug, it’s not possible to run the application, it’s possible only to debug.
Click “Apply” and that’s it.
- Now, we are able to set the breakpoint and connect our debugger.
- Now, let’s try to open the next url in the browser: http://192.168.33.10:3000/?param=123 .
If everything is setup correctly, you will be brought back to the WebStorm right to the middle of the debug session:
- Cool, you don’t need to spoil your private PC with all kinds of software needed to run your application, but you still can debug it in the convenient way. As you understand – configuring the remote debug for any other server where you run your node application would be the same. You can debug your AWS or digitalocean node applications as well, just be sure, that the debug port is accessible from the PC where you run the WebStorm.