Part 26. Debugging Node.js
- Most basic debugging tool: Use
console.log()
to print the values in variables - Node debugger
- Use
debugger
in your JavaScript file where you want the program to pause - Run Node with the inspect command line option
- $ node inspect …
- Use the
restart
command at thedebug>
prompt to restart the program. - Use
ctrl+c
twice to terminate the debugger
- When debugging, open Chrome and navigate to chrome://inspect
- Add your application folder to the inspection file system (+)
- Resume script execution
- View the variables that are in scope in the right hand side pane
- Use the console to print the value of the variables in scope
- Use
Part 27. Error Messages
Use the stack trace to find the location of the error.
© 2020 – 2024, Eric McGregor. All rights reserved. Unauthorized use, distribution and/or duplication of this material without express and written permission from the author is strictly prohibited.