Debugging NodeJS application with WebStorm

文章出处:http://blog.zakkum.com/?p=63


注意:刚开始用webstorm debug nodejs的时候,总会出现一个端口一会儿能用,一会不能用的情况。

其实你的debug设置可能没有问题,出问题的是你已经监听的端口没有断开


I would like to show you how to debug your nodejs web server applications. I’m using JetBrains’ WebStorm for some time and it’s my favourite web development tool for linux box. It’s 2.1 version. There is a nodejs plugin for debug operation in WebStorm. You can search and install plugin from File->Settings->Plugins window.

settings.jpg

I assume that you have installed nodejs and express already. You can grab nodejs from https://github.com/joyent/node and follow installation instructions. It’s quite easy. Then you can install express with
npm install -d express

There is a “Hello world” application to test our server. Create a new javascript file and name it “app.js”

var app = require('express').createServer();
app.get('/', function(req, res){
res.send('Hello world');
});
app.listen(3000);
console.log('Server started on port 3000');

Click Run->Debug… or press alt+shift+f9 to open debug configuration screen. Click plus icon and then click nodejs option.

debug2.jpg

Give a name to your configuration. Enter your node path (get node path from terminal: which node) and type your app.js file path.

debug3.jpg

Now we are all set for debugging. Hit the debug button or press shift+f9 and you will see “debugger listenin on port …” message in console. You can make breakpoints to debug your application.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值