How do I debug Node.js applications?

后端 未结 30 2072
暗喜
暗喜 2020-11-22 05:56

How do I debug a Node.js server application?

Right now I\'m mostly using alert debugging with print statements like this:

sys.puts(sys.inspe         


        
相关标签:
30条回答
  • 2020-11-22 06:24

    Assuming you have node-inspector installed on your computer (if not, just type 'npm install -g node-inspector') you just have to run:

    node-inspector & node --debug-brk scriptFileName.js
    

    And paste the URI from the command line into a WebKit (Chrome / Safari) browser.

    0 讨论(0)
  • 2020-11-22 06:27

    The V8 debugger released as part of the Google Chrome Developer Tools can be used to debug Node.js scripts. A detailed explanation of how this works can be found in the Node.js GitHub wiki.

    0 讨论(0)
  • 2020-11-22 06:27

    There is built-in command line debugger client within Node.js. Cloud 9 IDE have also pretty nice (visual) debugger.

    0 讨论(0)
  • 2020-11-22 06:27

    There are many possibilities...

    • node includes a debugging utility
    • node-inspector
    • Code editors / IDEs (see debug instructions for one of the following)
      • Atom,
      • VSCode
      • Webstorm
      • and more

    Debug support is often implemented using the v8 Debugging Protocol or the newer Chrome Debugging Protocol.

    0 讨论(0)
  • 2020-11-22 06:28

    Debugging

    • Joyent's Guide
    • Debugger
    • Node Inspector
    • Visual Studio Code
    • Cloud9
    • Brackets

    Profiling

    1. node --prof ./app.js
    2. node --prof-process ./the-generated-log-file

    Heapdumps

    • node-heapdump with Chrome Developer Tools

    Flamegraphs

    • 0x
    • jam3/devtool then Chrome Developer Tools Flame Charts
    • Dtrace and StackVis — Only supported on SmartOS
    • clinicjs

    Tracing

    • Interactive Stack Traces with TraceGL

    Logging

    Libraries that output debugging information

    • Caterpillar
    • Tracer
    • scribbles

    Libraries that enhance stack trace information

    • Longjohn

    Benchmarking

    • Apache Bench: ab -n 100000 -c 1 http://127.0.0.1:9778/
    • wrk

    Other

    • Trace
    • Vantage
    • Bugger
    • Google Tracing Framework
    • Paul Irish's Guide

    Legacy

    These use to work but are no longer maintained or no longer applicable to modern node versions.

    • https://github.com/bnoordhuis/node-profiler - replaced by built-in debugging
    • https://github.com/c4milo/node-webkit-agent - replaced by node inspector
    • https://nodetime.com/ - defunct
    0 讨论(0)
  • 2020-11-22 06:28

    Theseus is a project by Adobe research which lets you debug your Node.js code in their Open Source editor Brackets. It has some interesting features like real-time code coverage, retroactive inspection, asynchronous call tree.

    screenshot

    0 讨论(0)
提交回复
热议问题