SlideShare a Scribd company logo
Pittsburgh
 http://www.meetup.com/Pittsburgh-Node-js/




Last Wednesday of every month 7-9pm
      Right here at LeBrew House!
Nicholas McClay
Designer and Developer




     @nickmcclay
Debugging
goodbye console.log()
In the beginning there was ‘debugger’

 http://nodejs.org/api/debugger.html


 To debug in console:
 node debug test.js
 note: 'debug' not '--debug', this is a different command we'll see later




 This hook to V8's debugger is what all
 Node debug tools bind to.
Debug command highlights
• Stepping
  – cont, next, step, out - What you think they do
• Breakpoints
  – setBreakpoint()/sb() - Set breakpoint on current
    line or at statement
  – clearBreakpoint/clearBreakpoint()/cb(...) - clear
    breakpoint (duh)
Debug command highlights
• Info
  –   backtrace/bt - Print backtrace of current execution frame
  –   watch(expr) - Add expression to watch list
  –   unwatch(expr) - Remove expression from watch list
  –   watchers - List all watchers and their values
  –   repl - Open debugger's repl for evaluation in debugging
      script's context

• Execution control
  – run - Run script (automatically runs on debugger's start)
  – restart - Restart script
  – kill - Kill script
Can’t we use something a little less…




   Arcane? Unusual? Ugly? 1990?
Eclipse IDE
Eclipse Node Debugger Walk Through:
https://github.com/joyent/node/wiki/Using-
Eclipse-as-Node-Applications-Debugger

Chrome Dev Tools + V8 Debugger:
http://code.google.com/p/chromedevtools/

Warning, plug-in compatibility can be a
nightmare! Aptana or other highly customized
Eclipse based IDE's may not work.
Eclipse advanced debugging
To debug with real source instead of
'VirtualProject' files
http://code.google.com/p/chromedevt
ools/wiki/FeatureDebugOnRealFiles

Screen capture of setup
http://www.youtube.com/watch?v=GV
xFFw7lkYg
Webstorm IDE
Happy Node.js
debugging right out
of the box!

Coffeescript
debugging coming in
version 4.0!
Other IDEs




Komodo IDE
node-inspector
 Webkit Inspector debugging
 https://github.com/dannycoates/node-inspector

 front-end JavaScript debugger reused
 for back-end JavaScript, what a great
 idea!
1.) npm install –g node-inspector

2.) node --debug-brk test.js

3.) node-inspector
4.) Open browser to http://localhost:8080/debug?port=5858
Final Thoughts
• --debug vs --debug-brk

• Remote Debugging

• Long stack traces
http://stackoverflow.com/questions/7697038/more-
than-10-lines-in-a-node-js-stack-error
Thanks!

Questions?

More Related Content

PPTX
Intro to Node.js (v1)
PPT
Node.js Cloud deployment
KEY
Node.js 0.8 features
PPSX
Node.js In The Enterprise - A Primer
KEY
OSCON 2011 - Node.js Tutorial
PPTX
Node.js Patterns for Discerning Developers
PPTX
Introduction Node.js
KEY
Introduction to node.js
Intro to Node.js (v1)
Node.js Cloud deployment
Node.js 0.8 features
Node.js In The Enterprise - A Primer
OSCON 2011 - Node.js Tutorial
Node.js Patterns for Discerning Developers
Introduction Node.js
Introduction to node.js

What's hot (20)

PDF
Introduction to Node.js: What, why and how?
PDF
Node.js and How JavaScript is Changing Server Programming
PPTX
Introduction to Node.js
PPTX
Introduction to Node js
PPTX
introduction to node.js
PPTX
Introduction to node.js GDD
PDF
All aboard the NodeJS Express
PPTX
Nodejs intro
PPTX
Java script at backend nodejs
PDF
Use Node.js to create a REST API
PDF
NodeJS for Beginner
KEY
Writing robust Node.js applications
PPTX
Node js introduction
PDF
Node azure
PDF
Node.js Crash Course
PDF
PPTX
NodeJS - Server Side JS
PDF
Module, AMD, RequireJS
PDF
Building web apps with node.js, socket.io, knockout.js and zombie.js - Codemo...
PPTX
Node.js, for architects - OpenSlava 2013
Introduction to Node.js: What, why and how?
Node.js and How JavaScript is Changing Server Programming
Introduction to Node.js
Introduction to Node js
introduction to node.js
Introduction to node.js GDD
All aboard the NodeJS Express
Nodejs intro
Java script at backend nodejs
Use Node.js to create a REST API
NodeJS for Beginner
Writing robust Node.js applications
Node js introduction
Node azure
Node.js Crash Course
NodeJS - Server Side JS
Module, AMD, RequireJS
Building web apps with node.js, socket.io, knockout.js and zombie.js - Codemo...
Node.js, for architects - OpenSlava 2013
Ad

Similar to Node.js debugging (20)

PDF
Here Be Dragons – Advanced JavaScript Debugging
PDF
FITC - Here Be Dragons: Advanced JavaScript Debugging
PDF
Web a Quebec - JS Debugging
PPTX
concept of server-side JavaScript / JS Framework: NODEJS
PDF
PDF
🚀 Node.js Simplified – A Visual Guide for Beginners!
PDF
SWT Tech Sharing: Node.js + Redis
PPTX
Nodejs Session01
PDF
Node Interactive Debugging Node.js In Production
PDF
540slidesofnodejsbackendhopeitworkforu.pdf
PPTX
Introduction to node.js
PDF
Node.js introduction
PDF
Debugging, a step away from the console
PDF
Day In A Life Of A Node.js Developer
PDF
Day in a life of a node.js developer
PPTX
Introduction to node.js By Ahmed Assaf
PDF
Debugging secrets of the pros, for everyone
PDF
Server-Side JavaScript Developement - Node.JS Quick Tour
PPTX
Server Side Web Development Unit 1 of Nodejs.pptx
PDF
Introduction to Node.js
Here Be Dragons – Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript Debugging
Web a Quebec - JS Debugging
concept of server-side JavaScript / JS Framework: NODEJS
🚀 Node.js Simplified – A Visual Guide for Beginners!
SWT Tech Sharing: Node.js + Redis
Nodejs Session01
Node Interactive Debugging Node.js In Production
540slidesofnodejsbackendhopeitworkforu.pdf
Introduction to node.js
Node.js introduction
Debugging, a step away from the console
Day In A Life Of A Node.js Developer
Day in a life of a node.js developer
Introduction to node.js By Ahmed Assaf
Debugging secrets of the pros, for everyone
Server-Side JavaScript Developement - Node.JS Quick Tour
Server Side Web Development Unit 1 of Nodejs.pptx
Introduction to Node.js
Ad

Recently uploaded (20)

PDF
Chapter 3 Spatial Domain Image Processing.pdf
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PPTX
MYSQL Presentation for SQL database connectivity
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
MIND Revenue Release Quarter 2 2025 Press Release
PPTX
sap open course for s4hana steps from ECC to s4
PDF
Electronic commerce courselecture one. Pdf
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PDF
cuic standard and advanced reporting.pdf
PPTX
Spectroscopy.pptx food analysis technology
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PDF
Encapsulation theory and applications.pdf
PDF
Approach and Philosophy of On baking technology
PDF
Mobile App Security Testing_ A Comprehensive Guide.pdf
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PPT
Teaching material agriculture food technology
Chapter 3 Spatial Domain Image Processing.pdf
Assigned Numbers - 2025 - Bluetooth® Document
MYSQL Presentation for SQL database connectivity
NewMind AI Weekly Chronicles - August'25-Week II
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Programs and apps: productivity, graphics, security and other tools
MIND Revenue Release Quarter 2 2025 Press Release
sap open course for s4hana steps from ECC to s4
Electronic commerce courselecture one. Pdf
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
cuic standard and advanced reporting.pdf
Spectroscopy.pptx food analysis technology
The AUB Centre for AI in Media Proposal.docx
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
Encapsulation theory and applications.pdf
Approach and Philosophy of On baking technology
Mobile App Security Testing_ A Comprehensive Guide.pdf
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
Teaching material agriculture food technology

Node.js debugging

  • 2. Nicholas McClay Designer and Developer @nickmcclay
  • 4. In the beginning there was ‘debugger’ http://nodejs.org/api/debugger.html To debug in console: node debug test.js note: 'debug' not '--debug', this is a different command we'll see later This hook to V8's debugger is what all Node debug tools bind to.
  • 5. Debug command highlights • Stepping – cont, next, step, out - What you think they do • Breakpoints – setBreakpoint()/sb() - Set breakpoint on current line or at statement – clearBreakpoint/clearBreakpoint()/cb(...) - clear breakpoint (duh)
  • 6. Debug command highlights • Info – backtrace/bt - Print backtrace of current execution frame – watch(expr) - Add expression to watch list – unwatch(expr) - Remove expression from watch list – watchers - List all watchers and their values – repl - Open debugger's repl for evaluation in debugging script's context • Execution control – run - Run script (automatically runs on debugger's start) – restart - Restart script – kill - Kill script
  • 7. Can’t we use something a little less… Arcane? Unusual? Ugly? 1990?
  • 8. Eclipse IDE Eclipse Node Debugger Walk Through: https://github.com/joyent/node/wiki/Using- Eclipse-as-Node-Applications-Debugger Chrome Dev Tools + V8 Debugger: http://code.google.com/p/chromedevtools/ Warning, plug-in compatibility can be a nightmare! Aptana or other highly customized Eclipse based IDE's may not work.
  • 9. Eclipse advanced debugging To debug with real source instead of 'VirtualProject' files http://code.google.com/p/chromedevt ools/wiki/FeatureDebugOnRealFiles Screen capture of setup http://www.youtube.com/watch?v=GV xFFw7lkYg
  • 10. Webstorm IDE Happy Node.js debugging right out of the box! Coffeescript debugging coming in version 4.0!
  • 12. node-inspector Webkit Inspector debugging https://github.com/dannycoates/node-inspector front-end JavaScript debugger reused for back-end JavaScript, what a great idea! 1.) npm install –g node-inspector 2.) node --debug-brk test.js 3.) node-inspector 4.) Open browser to http://localhost:8080/debug?port=5858
  • 13. Final Thoughts • --debug vs --debug-brk • Remote Debugging • Long stack traces http://stackoverflow.com/questions/7697038/more- than-10-lines-in-a-node-js-stack-error