I have a burning question in my head regarding debugging, you see when I am writing Javascript client side I can go to Chrome's console and track my variables and objects etc to see what is happening with my code better.. I am just not able to get my head around about how can we do the same on the server side (node js)? Let's say my front end submitted a form to my express server, how do I go about checking if for instance the req object even received it or not? where do I go about checking variables and objects (debugging) server side code? I definitely can't do it on console of browser as the code exists and executes on the server side so I can't access server side objects etc through browser's console.
In a similar way to auto attach, the JavaScript Debug Terminal will automatically debug any Node. js process you run in it. You can create a Debug Terminal by running the Debug: Create JavaScript Debug Terminal command from the Command Palette ( kbs(workbench. action.
You can still do console.log(). It'll print to the screen where you run the server. However, it's not as good as walking through the code with debugger which you can set breakpoints and do lots of other things debuggers can do. I've used both webstorm's debugger and node-inspector.
You might want to look into node-inspector. The debugger is like Chrome's Dev-Tool, which you might be familiar with. The link below provides everything from installation to tutorials.
https://github.com/node-inspector/node-inspector
Node comes with a REPL (Read-Eval-Print-Loop). It works a bit like the console of chrome but requires a bit of configuration and set up of it's scope.
Here is an example: http://derickbailey.com/2014/07/02/build-your-own-app-specific-repl-for-your-nodejs-app/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With