- 安装node
下载node : http://nodejs.org/
cd tmp/
tar -zxvf node-v0.6.17.tar.gz
cd node-v0.6.17/
./configure --prefix=/home/jack/program/node
make
sudo make install
sudo vim /etc/profile.d/node_config.sh
export PATH=$PATH:/home/jack/program/node/bin
export NODE_PATH="/home/jack/program/node:/home/jack/program/node/lib/node_modules"
node -v #查看node版本
npm -v #查看npm版本
- node调试工具
1.基于Nodejs内建的调试器
example.js
var http = require('http');
var url = require('url');
http.createServer(function (req, res) {
var path = url.parse(req.url).pathname;
res.writeHead(200, {'Content-Type': 'text/plain'});
res.end(path);
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');
node debug example.js
通过help命令来获取完整的调试命令列表
2.基于V8插件的调试器安装google v8调试器插件 : http://chromedevtools.googlecode.com/svn/update/dev/
3.基于Chrome浏览器的调试器npm install -g node-inspector
node-inspector
node --debug#或--debug-brk example.js
http://localhost:8080/debug?port=5858 #打开chrome调试器 , 设置断点
http://localhost:1337/ #访问页面 , 进入断点