新建一个普通的project。
编写如下代码:
var http=require('http'); http.createServer(function(req,res){ res.writeHead(200,{'Content-Type':'text/plain'}); res.end('Hello World This is my first NodeJs'); }).listen(2222,'127.0.0.1'); console.log("Server running at http:127.0.0.1:2222");
此时,右键如下图所示:
点击运行。此时我们可以打开浏览器,测试刚启动的这段代码。
图示如下:
或者搞web开发,直接创建一个express工程。
新建一个node.js express project:
会自动帮你配置 express mvc 框架。
webstorm对Node.js有很好的调试功能。调试时只要点击run按钮,软件就会自动启动控制台。操作简单,多尝试就能学会。
在浏览器中访问相关地址http://localhost:3000/
http://www.cnblogs.com/enix/archive/2012/04/29/2475983.html