Node.js是一個可以快速構建網絡服務及應用的平台。該平台的構建是基於Chrome's JavaScript runtime,也就是說,實際上它是對Google V8引擎(應用於Google Chrome瀏覽器)進行了封裝。 今天介紹Node.js調式目前有幾種方法,Built-in的調試功能我們在這兒不介紹了,在這兒主要介紹第三方的,第一種方法使用:node-inspector:
通過npm來安裝:
$ npm install -g node-inspector
用以下方法來啟動調試:
$ node-debug app.js
然后自動打開默認瀏覽器,http://127.0.0.1:8080/debug?port=5858, 這里推薦Google Chrome Developer Tools,如下圖所示:
可以看到Call Stack,Scope Variables. 支持單步調試。
第二種方法,使用商業產品 WebStorm IDE,是jetbrains公司旗下一款JavaScript 開發工具。被廣大中國JS開發者譽為“Web前端開發神器”、“最強大的HTML5編輯器”、“最智能的JavaScript IDE”等。
安裝以后,打開相應的項目,Debug如下圖:
從UI界面上,提供了詳盡的信息,breakpoint, console,scripts,variables.
還有一些Node.js相關的工具:
Profiling with node Profiler
CPU and Memory Profiling with NodeTime, look
Webkit Developer Tools Profiling with Node Webkit Agent
Interactive Cloud9 Debugging Guide here
Heapdumps to Webkit Developer Tools Tool and guide here
Logging Libraries that output Debugging Information Caterpillar Tracer
Flamegraphs with Dtrace and StackVis Only supported on SmartOS
希望對您軟件開發有幫助。
您可能感興趣的文章:
作者:Petter Liu
出處:http://www.cnblogs.com/wintersun/
本文版權歸作者和博客園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接,否則保留追究法律責任的權利。
該文章也同時發布在我的獨立博客中-Petter Liu Blog。