sublime配置开发nodejs

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,古老的榕树,5-wow.com

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。