Sublime Text3 手动 配置 NodeJs 环境

不会自动配,就手动配

 

https://github.com/tanepiper/SublimeText-Nodejs 下载 downzip
放到,首选项,浏览插件,我的是下面的目录
D:\soft\Sublime Text 3\Data\Packages
SublimeText-Nodejs-master.zip
解压,名称改为SublimeText-Nodejs
修改

Nodejs.sublime-settings

{
// 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": false,

"expert_mode": false,

"ouput_to_new_tab": false
}

  

Nodejs.sublime-build

{
"cmd": ["node", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js",
"shell": true,
"encoding": "cp936",
"windows":
{
"cmd": ["taskkill","/F", "/IM", "node.exe","&","node", "$file"]
},
"linux":
{
"shell_cmd": "killall node; /usr/bin/env node $file"
},
"osx":
{
"shell_cmd": "killall node; /usr/bin/env node $file"
}
}

找到工具,编译系统,选择node.js

新建test.js

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(3000);

console.log('Server running at http://127.0.0.1:3000/');

 

然后ctrl+B 在浏览器查看 http://127.0.0.1:3000/

参考教程

http://www.cnblogs.com/qiaojie/p/5560388.html

http://www.cnblogs.com/bluesky4485/p/3928364.html

posted @ 2017-06-16 22:45  败草麦麦  阅读(318)  评论(0编辑  收藏  举报