赞
踩
在装好node和sublime Text之后,配置sublime Text3。
https://github.com/tanepiper/SublimeText-Nodejs
直接改名为nodejs 放到 Preferences–>浏览程序包Browse Packages所在的文件夹
打开Nodejs文件夹,找到文件“Nodejs.sublime-build”, 拖拽到sublime,显示:
{
"cmd": ["node", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js",
"shell":true,
"encoding": "cp1252",
"windows":
{
"cmd": ["taskkill /F /IM node.exe & node", "$file"]
},
"linux":
{
"cmd": ["killall node; node", "$file"]
}
}
修改为
{
"cmd": ["node", "$file"],
"file_regex": "^[ ]*File \"(...*?)\", line ([0-9]*)",
"selector": "source.js",
"shell":true,
"encoding": "utf-8",
"windows":
{
"cmd": ["taskkill /F /IM node.exe", ""],
"cmd": ["node", "$file"]
},
"linux":
{
"cmd": ["killall node; node", "$file"]
}
}
随便写一段nodejs代码,ctrl+B运行(附上mysql测试连接)
/**
* Created by zly on 2015/7/15.
*/
var mysql = require('mysql');
var option = {
host: 'localhost',
port: '3306',
database: 'bi-demo',
user: 'root',
password: 'root'
};
var connection = mysql.createConnection(option);
connection.connect(function (err) {
if (err) {
console.log("mysql open connection failure");
} else {
console.log("mysql open connection success");
connection.query("select * from feedata", function (err, result) {
console.log(result);
});
connection.end(function (err) {
if (err) {
console.log("mysql close connection failure");
} else {
console.log("mysql close connection success");
}
});
}
})
console.log("hello");
在手动解压sublime Text插件后,需要在preference->package settings->package control的user setting下添加installed packages中的“Nodejs”,不然重启sublime Text 会被删除Nodejs插件。
{
"bootstrapped": true,
"in_process_packages":
[
],
"installed_packages":
[
"Alignment",
"Colorcoder",
"ConvertToUTF8",
"CTags",
"Git",
"Github Tools",
"Nodejs",
"Package Control",
"PHPIntel",
"SFTP",
"SublimeCodeIntel",
"Tag",
"TortoiseSVN",
"Xdebug Client"
]
}
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。