14
Pittsburgh http:// www.meetup.com /Pittsburgh-Node- js / Last Wednesday of every month 7-9pm Right here at LeBrew House!

Node.js debugging

Embed Size (px)

DESCRIPTION

Pittsburgh Node.js presentation explaining the different options available for Node.js across IDEs, command line, and node modules.

Citation preview

Page 2: Node.js debugging

Nicholas McClayDesigner and Developer

@nickmcclay

Page 3: Node.js debugging

Debugginggoodbye console.log()

Page 4: Node.js debugging

In the beginning there was ‘debugger’

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

To debug in console:

This hook to V8's debugger is what all Node debug tools bind to.

node debug test.jsnote: 'debug' not '--debug', this is a different command we'll see later

Page 5: Node.js debugging

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)

Page 6: Node.js debugging

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

Page 7: Node.js debugging

Can’t we use something a little less…

Arcane? Unusual? Ugly? 1990?

Page 10: Node.js debugging

Webstorm IDE

Happy Node.js debugging right out of the box!

Coffeescript debugging coming in version 4.0!

Page 11: Node.js debugging

Other IDEs

Komodo IDE

Page 12: Node.js debugging

node-inspectorWebkit Inspector debugginghttps://github.com/dannycoates/node-inspector

front-end JavaScript debugger reused for back-end JavaScript, what a great idea!

npm install –g node-inspector1.)

node --debug-brk test.js2.)

node-inspector3.)

4.) Open browser to http://localhost:8080/debug?port=5858

Page 14: Node.js debugging

Thanks!

Questions?