- Using console object: console.log(‘xxx‘);
- Using Node.js internal debugger (v8 engine): node debug xxx.js
refer to: https://nodejs.org/api/debugger.html#debugger_debugger
- Using node-inspector:https://github.com/node-inspector/node-inspector
How to use node-inspector:
- In one terminal, run "node-inspector" to start the node inspector server.
- In another terminal, run
node --debug your/node/program.js
-
Or
node --debug-brk your/short/node/script.js // pause your script on the first line
to start your node process.
- Launch Chrome or Opera, open http://127.0.0.1:8080/debug?port=5858 to
launch debugger UI. (Server code can be shown here)- You can set breakpoint to code (although you may cannot see the breakpoint first time, click "Refresh" button on browser, you can see program will stop at the breakpoint you set last time.)
时间: 2024-10-31 16:07:20