首页 > Web开发 > 详细

NodeJS开发环境配置

时间:2014-03-31 11:26:08      阅读:549      评论:0      收藏:0      [点我收藏+]

"Node.js 是服务器端的 JavaScript 运行环境,它具有无阻塞(non-blocking)和事件驱动(event-driven)等的

特色,Node.js 采用 V8 引擎,同样,Node.js 实现了类似 Apache 和 nginx 的web服务,让你可以通过它来

搭建基于 JavaScript 的 Web App。"

配置NodeJS环境

我的环境是VS2013 + nodejs + nodejstools
nodejs:
http://nodejs.org
codeplex:  https://nodejstools.codeplex.com

bubuko.com,布布扣

示例

bubuko.com,布布扣
var http = require(‘http‘);
var port = process.env.port || 1337;
//加载文件模块
var fs=require(‘fs‘); 
http.createServer(function (req, rep) {
    rep.writeHead(200, { ‘Content-Type‘: ‘text/plain‘ });
     fs.readFile(‘package.json‘,‘utf-8‘,function(err,data){ 
       if (err) {
           console.log(err);
       }else{  
         rep.write(data);
         rep.end(‘Hello World\n‘);
      }
     });
}).listen(port);
console.log(‘NodeJS Server running!‘);
bubuko.com,布布扣

Refer:
http://nodejstools.codeplex.com/documentation
http://www.hanselman.com/blog/IntroducingNodejsToolsForVisualStudio.aspx

NodeJS开发环境配置,布布扣,bubuko.com

NodeJS开发环境配置

原文:http://www.cnblogs.com/Irving/p/3634232.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!