Electron app cant find sqlite3 module(电子应用程序找不到 sqlite3 模块)
问题描述
在我的电子应用中,我通过 npm 安装了 sqlite3
In my electron app I have installed sqlite3 via npm
npm install sqlite3
但是一旦我尝试与数据库交互,它就找不到数据库,这是日志:
But once i try to interact with the database it cant find the database, here is the log:
未捕获的错误:找不到模块 'D:playelectron-quick-start ode_modulessqlite3libindingelectron-v1.3-win32-x64 ode_sqlite3.node'
Uncaught Error: Cannot find module 'D:playelectron-quick-start ode_modulessqlite3libindingelectron-v1.3-win32-x64 ode_sqlite3.node'
这里是JS代码:
console.log('whooooo');
var sqlite3 = require('sqlite3').verbose();
var db = new sqlite3.Database('../db/info.db');
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();
我也是这样尝试的:
npm install sqlite3 --build-from-source
但安装失败!
另外,我正在使用 Python3.你如何安装一个模块来使用电子?
Also, i am using Python3. How do you install a module to work with electron?
推荐答案
首先:
npm install electron-rebuild
然后多试几次:
./node_modules/.bin/electron-rebuild -w sqlite3 -p
这篇关于电子应用程序找不到 sqlite3 模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:电子应用程序找不到 sqlite3 模块


基础教程推荐
- Sql Server 字符串到日期的转换 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01