Electron sqlite3_1.default.database不是构造函数
我安装在我的Electron React Typescript网页包应用程序Electron sqlite3_1.default.database不是构造函数,electron,node-sqlite3,Electron,Node Sqlite3,我安装在我的Electron React Typescript网页包应用程序sqlite3中,通过纱线:纱线添加sqlite3@latest 并使用重建-f-w sqlite3重建了所有内容 在webpack.config.js中,我放了: const webpack = require('webpack'); externals: [ { 'sqlite3': sqlite3, } ], 如果在main.tsI中输入: import s
sqlite3
中,通过纱线:纱线添加sqlite3@latest
并使用重建-f-w sqlite3重建了所有内容
在webpack.config.js
中,我放了:
const webpack = require('webpack');
externals: [
{
'sqlite3': sqlite3,
}
],
如果在main.ts
I中输入:
import sqlite3 from 'sqlite3';
let db = new sqlite3.Database(
path.join(app.getPath('userData'),'/infopiecesleveldb'),
(err) => {
if (err) {
return console.error(err.message);
}
console.log('Connected to the in-memory SQlite database.');
});
我得到这个错误:sqlite3\u 1.default.database不是构造函数
(node:2679) UnhandledPromiseRejectionWarning: TypeError: sqlite3_1.default.database is not
a constructor
at App.<anonymous> (/home/marco/webMatters/electronMatters/Raphy-Template/dist/main
/main.js:60:32)
at App.emit (events.js:315:20)
(Use `electron --trace-warnings ...` to show where the warning was created)
(node:2679) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error
originated either by throwing inside of an async function without a catch block, or by
rejecting a promise which was not handled with .catch(). To terminate the node process on
unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see
https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2679) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In
the future, promise rejections that are not handled will terminate the Node.js process with
a non-zero exit code.
mainWindow loaded
(节点:2679)未处理的PromisejectionWarning:TypeError:sqlite3\u 1.default.database未被处理
构造器
在应用程序。(/home/marco/webMatters/electronimatters/graphic Template/dist/main
/main.js:60:32)
在App.emit上(events.js:315:20)
(使用'electron--trace warnings…`显示警告的创建位置)
(节点:2679)未处理的PromisejectionWarning:未处理的承诺拒绝。这个错误
通过在没有catch块的情况下抛出异步函数内部,或通过
拒绝未使用.catch()处理的承诺。要终止上的节点进程,请执行以下操作:
未处理的承诺拒绝,请使用CLI标志“---unhandled rejections=strict”(请参阅
https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (拒绝id:1)
(节点:2679)[DEP0018]弃用警告:未处理的承诺拒绝已弃用。在里面
将来,未处理的承诺拒绝将终止Node.js进程
非零退出代码。
主窗口已加载
关于如何解决这个问题有什么想法吗?
import sqlite3 from 'sqlite3';
//let db = new sqlite3.Database(':memory:', (err) => {
let db = new sqlite3.Database(
path.join(app.getPath('userData'),'/infopiecessql3db'),
(err) => {
if (err) {
return console.error(err.message);
}
console.log('Connected to the in-memory SQlite database.');
});
db.close();
现在,我将此消息连接到内存中的SQlite数据库