备忘 - nodejs sublime 环境
1.安装 sublime text
2.下载 nodejs sublime 插件,下载地址:https://github.com/tanepiper/SublimeText-Nodejs
在 sublime text 中 ctrl + shift + p 输入 package 选择 browse package 回车
在弹出的文件夹中创建 Nodejs 文件夹
深层目录解压插件到 Nodejs 文件夹中
3.在 Nodejs 文件夹中找到 Nodejs.sublime-build 将编码字符集改为 cp936
{
"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":
{
"cmd": ["killall node; node", "$file"]
},
"osx":
{
"cmd": ["killall node; node $file"]
}
}
4. ctrl + shit + p 输入 setting 选择 setting - 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": "E:/ide/nodejs/node.exe",
// Same for NPM command
"npm_command": "E:/ide/nodejs/npm.cmd",
// as 'NODE_PATH' environment variable for node runtime
"node_path": false,
"expert_mode": false,
"ouput_to_new_tab": false
}
5.写一个demo.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/