Sublime text2编译运行node.js程序

安装插件

1
git clone git://github.com/tanepiper/SublimeText-Nodejs.git ~/Library/Application\ Support/Sublime\ Text\ 2/Packages/Nodejs

配置

/private/var/root/Library/Application Support/Sublime Text 2/Packages下修改连个配置文件:

Nodejs.sublime-settings:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
// 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": "/usr/local/bin/node",
// Same for NPM command
"npm_command": "/usr/local/bin/npm",
// as 'NODE_PATH' environment variable for node runtime
"node_path": false,

"expert_mode": false,

"ouput_to_new_tab": false
}

Nodejs.sublime-build:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
{
"cmd": ["/usr/local/bin/node", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js",
"shell":false,
"encoding": "utf8",
"windows":
{
"cmd": ["taskkill /F /IM node.exe & node", "$file"]
}
,

"linux":
{
"cmd": ["killall node; node", "$file"]
}

}

shell配为false

运行

ctrl+b即可,或者右键.