首页 > Web开发 > 详细

sublime配置开发nodejs

时间:2014-04-14 10:13:22      阅读:674      评论:0      收藏:0      [点我收藏+]

1.下载https://github.com/tanepiper/SublimeText-Nodejs

2.解压到sublime->Preferences->Browse Packages 打开的目录,然后改名nodejs

3.重启sublime,选择Tools->Build System->nodejs

4.打开Preferences->Package Settings->Nodejs->Default配置如下:

{
// save before running commands
"save_first": true,
// if present, use this command instead of plain "node"
// e.g. "/usr/bin/node" or "C:\bin\node.exe"
"node_command": "C:\\Program Files\\nodejs\\node.exe",
// Same for NPM command
"npm_command": "C:\\Program Files\\nodejs\\npm.cmd",
// as ‘NODE_PATH‘ environment variable for node runtime
"node_path": "C:\\Program Files\\nodejs",

"expert_mode": false,

"ouput_to_new_tab": false
}

5.打开插件包中的Nodejs.sublime-build配置如下:

{
"cmd": ["node", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js",
"shell":true,
"encoding": "GB2312",
"windows":
{
"cmd": ["node", "$file"]
},
"linux":
{
"cmd": ["killall node; node", "$file"]
}
}

 

6 测试 编写如下代码

var http = require(‘http‘);
var os = require(‘os‘);

http.createServer(function (request, response) {
response.writeHead(200, {‘Content-Type‘: ‘text/plain‘});
response.end(‘Hello World\n‘);

}).listen(8124);

console.log(‘Server running at http://127.0.0.1:8124/‘);

然后按ctrl+B查看

 

 

sublime配置开发nodejs,布布扣,bubuko.com

sublime配置开发nodejs

原文:http://www.cnblogs.com/yfann/p/3662882.html

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