Overview
This short extra assumes:
If you do not, go there to learn or get a refresh.
If you develop your code in Eclipse or a similar IDE, then you can debug JS code just like you would debug a Java project. I use IntelliJ IDEA. I hear Visual Code is also good…
All modern browsers know have similar JavaScript debugging environments:
The name of the environment varies: Web Inspector, Inspector, Developer Tools…
If you do not have experience with debugging JavaScript in an IDE, but already know how to debug JS code in the browser, then you can use the browser debugger as a remote debugger for your server.
Run the server with “-inspect” option:
node --inspect server.js 8000
Then run Chrome on the same computer and go to URL: chrome://inspect
--inspect
option. Choose the relevant one.To debug a server, you can use your favorite browser.
Or you can use a simple command line tool named curl
curl http://localhost:8000/foo
requests the written url with GETcurl -i http://localhost:8000/foo
requests the written url and prints the response headerscurl -I http://localhost:8000/foo
requests the written url with method HEAD and prints just the headerscurl -X METHOD http://localhost:8000/foo/bar/3 ...
does the request with method METHOD (POST, PUT, DELETE, …)curl exists by default on linux and macs, but here it is for windows.