windows7
安装electron
npm install electron -D
安装windows-build-tools,过程中很漫长,几经失败,后来按照这篇文档安装相关后才成功
(需要安装vs_buildtools,需要先安装.net framework 4.6)
npm install --global --production windows-build-tools
安装node-gyp
npm install -g node-gyp
构建sqlite3(--target=9.1.1是electron的版本)
npm install sqlite3 --build-from-source --runtime=electron --target=9.1.1 --dist-url=https://atom.io/download/electron
测试代码
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database(':memory:');
// 这段代码用来测试 SQLite
db.serialize(function() {
db.run("CREATE TABLE lorem (info TEXT)");
var stmt = db.prepare("INSERT INTO lorem VALUES (?)");
for (var i = 0; i < 10; i++) {
stmt.run("Ipsum " + i);
}
stmt.finalize();
db.each("SELECT rowid AS id, info FROM lorem", function(err, row) {
console.log(row.id + ": " + row.info);
});
});
db.close();