In the development of node. JS environment, debugging is a very painful thing, but with the development of the times, there are now many kinds of node environment code debugging methods, today I will note the way I use
Node-inspector:
Node-inspector interacts with users via web pages, a browser based on the WebKit kernel, such as chrome, Safari, or Maxthon (roaming browser), QQ browser, Sogou browser, etc.
To debug first install Node-inspector:
1. NPM install-g Node-inspector
2. After the installation is successful, you need to start
Locate the node-inspector file directory directly under the installation letter and enter the command directly:node-inspector to start
As you can see from the node-inspector default port of 8080, this can also be modified in the following way:
--web-port=[port]
Note: port=5858 in the URL refers to the debug port of node. JS
3. How do I debug the code next?
The Development node project basically will start from an interface point, launch this file will start the node project, the basic is node xx.js can, as long as the traditional way to add--debug or--DEBUG-BRK can
Note: –-debug and –-debug-brk differ, the former runs the script directly, while the latter pauses at the beginning of the script, waiting for the debugger to connect, and the debugger's instructions to run.
When successful, it will show
4. Go to Chrome browser debugging
Note: If http://127.0.0.1:8080/?port=5858 cannot be opened see if node-inspector is in the boot state
node. js in Chrome for debugging