sqlite3数据库在Electron中的开放

sqlite3数据库在Electron中的开放,electron,node-sqlite3,Electron,Node Sqlite3,在我的Electron React Typescript网页包应用程序中导入sql3没有问题: import sqlite3 from 'sqlite3'; 但当我在main.ts中添加这些行时: const sql3_cb = () => { console.log("Welcome to sql3"); } app.on('ready', async () => { createMainWindow(); const infopiecesSq

在我的Electron React Typescript网页包应用程序中导入sql3没有问题:

import sqlite3 from 'sqlite3';
但当我在main.ts中添加这些行时:

const sql3_cb = () => {
  console.log("Welcome to sql3");
}

app.on('ready', async () => {
  createMainWindow();

  const infopiecesSqliteDb = new sqlite3.database(
    path.join(app.getPath('userData'), '/infopiecessql3db'),
    sql3_cb,
  );
}
运行应用程序时,我收到以下错误(完整回溯):

(基本)marco@pc01:~/webMatters/electronMatters/Graphics模板$Thread
开始
纱线运行v1.22.5
$THEAN run build&electron./dist/main/main.js
$npx webpack--config./webpack.config.js
asset main.js 4.95 MiB[与发射进行比较](名称:main)
孤立模块263 KiB[孤立]138模块
运行时模块1.06 KiB 6模块
javascript模块3.6 MiB
可缓存模块3.59 MiB
按路径划分的模块。/node_模块/3.58 MiB 660模块
按路径划分的模块。/src/13.3 KiB 3模块
json模块374 KiB
按路径划分的模块。/node_modules/har schema/lib/*.json 6.93 KiB 18
模块
按路径排列的模块。/node_modules/iconv lite/encodings/tables/*.json
86.7 KiB 8模块
按路径划分的模块。/node_模块/node pre gyp/16.8 KiB 3模块
按路径划分的模块。/node_modules/ajv/lib/refs/*.json 5.58 KiB 3
模块
4个模块
./node_modules/node pre-gyp/lib/pre-binding.js 20:22-48中的警告
关键依赖项:依赖项的请求是一个表达式
@./node_modules/node pre-gyp/lib/node-pre-gyp.js 42:0-44
@./node_modules/sqlite3/lib/sqlite3-binding.js 1:13-36
@./node_modules/sqlite3/lib/sqlite3.js 2:14-45
@./src/main/main.ts 35:16-34
./node_modules/node pre-gyp/lib/util/compile.js 39:27-49中的警告
未找到模块:错误:无法解析“/home/marco”中的“npm”
/webMatters/Electronimatters/Graphics模板/node_模块/node pre-
gyp/lib/util'
@./node\u模块/node-pre-gyp/lib/sync^\.\/.*$./util/compile.js
/util/compile
@./node_模块/node pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
@./node_modules/sqlite3/lib/sqlite3-binding.js 1:13-36
@./node_modules/sqlite3/lib/sqlite3.js 2:14-45
@./src/main/main.ts 35:16-34
./node_modules/node pre-gyp/lib/util/versioning.js 17:20-67中的警告
关键依赖项:依赖项的请求是一个表达式
@./node\u模块/node pre-gyp/lib/sync^\.\/.*$./util/versioning.js
/util/版本控制
@./node_模块/node pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
@./node_modules/sqlite3/lib/sqlite3-binding.js 1:13-36
@./node_modules/sqlite3/lib/sqlite3.js 2:14-45
@./src/main/main.ts 35:16-34
./node_modules/sqlite3/lib/sqlite3-binding.js 4:14-35中的警告
关键依赖项:依赖项的请求是一个表达式
@./node_modules/sqlite3/lib/sqlite3.js 2:14-45
@./src/main/main.ts 35:16-34
4警告包含未显示的详细信息。
使用'stats.errorDetails:true'resp'--要显示的统计错误详细信息
信息技术
./node_modules/node gyp/lib/Find-VisualStudio.cs中出现错误9:6
模块分析失败:意外令牌(9:6)
目前,您可能需要一个合适的加载程序来处理此文件类型
未配置任何加载程序来处理此文件。看见
https://webpack.js.org/concepts#loaders
|//此脚本需要与PowerShell v2兼容才能在上运行
Windows 2008R2和Windows 7。
| 
>使用制度;
|使用系统文本;
|使用System.Runtime.InteropServices;
@./node_模块/node gyp/lib/sync^\.\/.*$./Find-VisualStudio.cs
@./node_模块/node gyp/lib/node-gyp.js 41:13-36 190:36-53
@./node_modules/node pre-gyp/lib/util/compile.js 29:28-55
@./node\u模块/node-pre-gyp/lib/sync^\.\/.*$./util/compile.js
/util/compile
@./node_模块/node pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
@./node_modules/sqlite3/lib/sqlite3-binding.js 1:13-36
@./node_modules/sqlite3/lib/sqlite3.js 2:14-45
@./src/main/main.ts 35:16-34
./node_modules/node pre-gyp/lib/info.js 14:14-32中出错
未找到模块:错误:无法解析“/home/marco”中的“aws sdk”
/webMatters/Electronimatters/Graphics模板/node_模块/node pre-
gyp/lib'
@./node\u模块/node-pre-gyp/lib/sync^\.\/.*$./info.js./info
@./node_模块/node pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
@./node_modules/sqlite3/lib/sqlite3-binding.js 1:13-36
@./node_modules/sqlite3/lib/sqlite3.js 2:14-45
@./src/main/main.ts 35:16-34
./node_modules/node pre-gyp/lib/publish.js 18:14-32中出错
未找到模块:错误:无法解析“/home/marco”中的“aws sdk”
/webMatters/Electronimatters/Graphics模板/node_模块/node pre-
gyp/lib'
@./node\u模块/node-pre-gyp/lib/sync^\.\/.*$./publish.js
/出版
@./node_模块/node pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
@./node_modules/sqlite3/lib/sqlite3-binding.js 1:13-36
@./node_modules/sqlite3/lib/sqlite3.js 2:14-45
@./src/main/main.ts 35:16-34
./node_modules/node pre-gyp/lib/unpublish.js 16:14-32中出错
未找到模块:错误:无法解析“/home/marco”中的“aws sdk”
/webMatters/Electronimatters/Graphics模板/node_模块/node pre-
gyp/lib'
@./node\u模块/node-pre-gyp/lib/sync^\.\/.*$./unpublish.js
/未出版
@./node_模块/node pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
@./node_modules/sqlite3/lib/sqlite3-binding.js 1:13-36
@./node_modules/sqlite3/lib/sqlite3.js 2:14-45
@./src/main/main.ts 35:16-34
./node_modules/node-pre-gyp/lib/util/nw-pre-gyp/index.html中出错
1:0
模块分析失败:意外令牌(1:0)
目前,您可能需要一个合适的加载程序来处理此文件类型
未配置任何加载程序来处理此文件。看见
https://webpack.js.org/concepts#loaders
> 
| 
| 
@./node\u模块/node-pre-gyp/lib/sync^\.\/.*$./util/nw-pre-
gyp/index.html
@./node_模块/node pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
@./node_modules/sqlite3/lib/sqlite3-binding.js 1:13-36
@./node_modules/sqlite3/lib/sqlite3.js 2:14-45
@./src/main/main.ts 35:16-34
3错误包含未显示的详细信息。
使用'stats.errorDetails:true'resp'--要显示的统计错误详细信息
信息技术
网页包5.31.2在12546毫秒内编译了5个错误和4个警告
按路径lib/pdfjs dist/web/4.55 MiB 341资产列出的资产
按路径列出的资产资产资产/1.4 MiB
按路径列出的资产资产/css/1.23 MiB 22资产
按路径列出的资产资产资产/PIC/
(base) marco@pc01:~/webMatters/electronMatters/Raphy-Template$ yarn 
start
yarn run v1.22.5
$ yarn run build && electron ./dist/main/main.js
$ npx webpack --config ./webpack.config.js
asset main.js 4.95 MiB [compared for emit] (name: main)
orphan modules 263 KiB [orphan] 138 modules
runtime modules 1.06 KiB 6 modules
javascript modules 3.6 MiB
  cacheable modules 3.59 MiB
    modules by path ./node_modules/ 3.58 MiB 660 modules
    modules by path ./src/ 13.3 KiB 3 modules
json modules 374 KiB
  modules by path ./node_modules/har-schema/lib/*.json 6.93 KiB 18
 modules
  modules by path ./node_modules/iconv-lite/encodings/tables/*.json 
86.7 KiB 8 modules
  modules by path ./node_modules/node-pre-gyp/ 16.8 KiB 3 modules
  modules by path ./node_modules/ajv/lib/refs/*.json 5.58 KiB 3 
modules
  4 modules

WARNING in ./node_modules/node-pre-gyp/lib/pre-binding.js 20:22-48
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js 42:0-44
 @ ./node_modules/sqlite3/lib/sqlite3-binding.js 1:13-36
 @ ./node_modules/sqlite3/lib/sqlite3.js 2:14-45
 @ ./src/main/main.ts 35:16-34

WARNING in ./node_modules/node-pre-gyp/lib/util/compile.js 39:27-49
Module not found: Error: Can't resolve 'npm' in '/home/marco 
/webMatters/electronMatters/Raphy-Template/node_modules/node-pre-
gyp/lib/util'
 @ ./node_modules/node-pre-gyp/lib/ sync ^\.\/.*$ ./util/compile.js 
./util/compile
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
 @ ./node_modules/sqlite3/lib/sqlite3-binding.js 1:13-36
 @ ./node_modules/sqlite3/lib/sqlite3.js 2:14-45
 @ ./src/main/main.ts 35:16-34

WARNING in ./node_modules/node-pre-gyp/lib/util/versioning.js 17:20-67
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/node-pre-gyp/lib/ sync ^\.\/.*$ ./util/versioning.js 
./util/versioning
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
 @ ./node_modules/sqlite3/lib/sqlite3-binding.js 1:13-36
 @ ./node_modules/sqlite3/lib/sqlite3.js 2:14-45
 @ ./src/main/main.ts 35:16-34

WARNING in ./node_modules/sqlite3/lib/sqlite3-binding.js 4:14-35
Critical dependency: the request of a dependency is an expression
 @ ./node_modules/sqlite3/lib/sqlite3.js 2:14-45
 @ ./src/main/main.ts 35:16-34

4 warnings have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show 
it.

ERROR in ./node_modules/node-gyp/lib/Find-VisualStudio.cs 9:6
Module parse failed: Unexpected token (9:6)
You may need an appropriate loader to handle this file type, currently 
no loaders are configured to process this file. See     
https://webpack.js.org/concepts#loaders
| // This script needs to be compatible with PowerShell v2 to run on    
Windows 2008R2 and Windows 7.   
| 
> using System;
| using System.Text;
| using System.Runtime.InteropServices;
 @ ./node_modules/node-gyp/lib/ sync ^\.\/.*$ ./Find-VisualStudio.cs
 @ ./node_modules/node-gyp/lib/node-gyp.js 41:13-36 190:36-53
 @ ./node_modules/node-pre-gyp/lib/util/compile.js 29:28-55
 @ ./node_modules/node-pre-gyp/lib/ sync ^\.\/.*$ ./util/compile.js  
./util/compile
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
 @ ./node_modules/sqlite3/lib/sqlite3-binding.js 1:13-36
 @ ./node_modules/sqlite3/lib/sqlite3.js 2:14-45
 @ ./src/main/main.ts 35:16-34

ERROR in ./node_modules/node-pre-gyp/lib/info.js 14:14-32
Module not found: Error: Can't resolve 'aws-sdk' in '/home/marco
/webMatters/electronMatters/Raphy-Template/node_modules/node-pre-
gyp/lib'
 @ ./node_modules/node-pre-gyp/lib/ sync ^\.\/.*$ ./info.js ./info
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
 @ ./node_modules/sqlite3/lib/sqlite3-binding.js 1:13-36
 @ ./node_modules/sqlite3/lib/sqlite3.js 2:14-45
 @ ./src/main/main.ts 35:16-34

ERROR in ./node_modules/node-pre-gyp/lib/publish.js 18:14-32
Module not found: Error: Can't resolve 'aws-sdk' in '/home/marco 
/webMatters/electronMatters/Raphy-Template/node_modules/node-pre-
gyp/lib'
 @ ./node_modules/node-pre-gyp/lib/ sync ^\.\/.*$ ./publish.js 
./publish
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
 @ ./node_modules/sqlite3/lib/sqlite3-binding.js 1:13-36
 @ ./node_modules/sqlite3/lib/sqlite3.js 2:14-45
 @ ./src/main/main.ts 35:16-34

ERROR in ./node_modules/node-pre-gyp/lib/unpublish.js 16:14-32
Module not found: Error: Can't resolve 'aws-sdk' in '/home/marco
/webMatters/electronMatters/Raphy-Template/node_modules/node-pre-
gyp/lib'
 @ ./node_modules/node-pre-gyp/lib/ sync ^\.\/.*$ ./unpublish.js 
./unpublish
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
 @ ./node_modules/sqlite3/lib/sqlite3-binding.js 1:13-36
 @ ./node_modules/sqlite3/lib/sqlite3.js 2:14-45
 @ ./src/main/main.ts 35:16-34

ERROR in ./node_modules/node-pre-gyp/lib/util/nw-pre-gyp/index.html 
1:0
Module parse failed: Unexpected token (1:0)
You may need an appropriate loader to handle this file type, currently
 no loaders are configured to process this file. See     
https://webpack.js.org/concepts#loaders
> <!doctype html>
| <html>
| <head>
 @ ./node_modules/node-pre-gyp/lib/ sync ^\.\/.*$ ./util/nw-pre-
gyp/index.html
 @ ./node_modules/node-pre-gyp/lib/node-pre-gyp.js 52:13-36 184:38-55
 @ ./node_modules/sqlite3/lib/sqlite3-binding.js 1:13-36
 @ ./node_modules/sqlite3/lib/sqlite3.js 2:14-45
 @ ./src/main/main.ts 35:16-34

3 errors have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show 
it.

webpack 5.31.2 compiled with 5 errors and 4 warnings in 12546 ms

assets by path lib/pdfjs-dist/web/ 4.55 MiB 341 assets
assets by path assets/ 1.4 MiB
  assets by path assets/css/ 1.23 MiB 22 assets
  assets by path assets/pics/ 170 KiB 9 assets
assets by path *.js 11.5 MiB 7 assets
assets by path lib/pdfjs-dist/build/ 6.3 MiB
  assets by path lib/pdfjs-dist/build/*.map 4 MiB 3 assets
  assets by path lib/pdfjs-dist/build/*.js 2.3 MiB 3 assets
assets by path *.html 28 KiB 5 assets
asset lib/pdfjs-dist/LICENSE 9.94 KiB [compared for emit] [from:    
src/lib/pdfjs-dist/LICENSE] [copied]
asset lib/infopiecemgr.js 2.77 KiB [compared for emit] [from: src/lib 
/infopiecemgr.js] [copied]
orphan modules 35.2 KiB [orphan] 118 modules
runtime modules 7.32 KiB 32 modules
modules by path ./node_modules/ 3.38 MiB 850 modules
modules by path ./src/ 132 KiB
  modules by path ./src/app/ 55.9 KiB 16 modules
  modules by path ./src/app_A/ 24.8 KiB 4 modules
  modules by path ./src/app_B/ 24.8 KiB 4 modules
  modules by path ./src/store/*.ts 3.5 KiB
    ./src/store/redux_hooks.ts 556 bytes [built] [code generated]
    ./src/store/store.ts 2.96 KiB [built] [code generated]
  modules by path ./src/assets/css/*.css 21 KiB
    ./src/assets/css/global.css 339 bytes [built] [code generated]
    ./node_modules/css-loader/dist/cjs.js!./src/assets/css/global.css   
20.7 KiB [built] [code generated]
  ./src/reducers/infopiece/infopieceSlice.ts 1.98 KiB [built] [code 
generated]
webpack 5.31.2 compiled successfully in 12552 ms
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about 
this command.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about   
this command.
(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 pro