Debugging Node/Express RESTful API with node-inspector
Try with nodedev
1) Install nodedev
:
sudo npm install -g nodedev
2) Start your server:
nodedev server.js
3) Visit the page http://127.0.0.1:7001/debug?port=7000
to debug...
4) ...
5) Profit!
Bonus: Your server will automatically restart when changes are detected!
Here is my solution: Do not use node-debug *.js directly. Instead, open two terminals in your project. For example, I want to debug server-3.js, like the pictures down here. In one terminal, use node-inspector for debugging listening, and another use node --debug server-3.js
after sending a request on postman:
you can see your debugging situation in your node-inspector window listening on port 5858:
I believe this is what you want to achieve.
The latest update is that you can also resort to vscode, which has a plugin called "Debugger for Chrome" that has the debug function you want.
Use node-inspector instead of node-debug (comes in the same module)In one terminal execute:node-inspector
In another terminal execute node --debug server.js