Javascript sqlite3在电子商务中的应用

Javascript sqlite3在电子商务中的应用,javascript,node.js,sqlite,npm,electron,Javascript,Node.js,Sqlite,Npm,Electron,我正在尝试使用sqlite3构建一个electron应用程序。现在我正在尝试将electron builder用于sqlite3,但即使在添加了安装后依赖项之后,我仍然会出错: My package.json: { "name": "store_electron", "version": "1.0.0", "description": "trying ", "main": "main.js", "scripts": { "test": "echo \"Error: n

我正在尝试使用sqlite3构建一个electron应用程序。现在我正在尝试将electron builder用于sqlite3,但即使在添加了安装后依赖项之后,我仍然会出错:

My package.json:

{
  "name": "store_electron",
  "version": "1.0.0",
  "description": "trying ",
  "main": "main.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "postinstall": "install-app-deps"
  },
  "author": "armelzong@gmail.com",
  "license": "ISC",
  "dependencies": {
    "sqlite3": "^4.2.0"
  },
  "devDependencies": {
    "electron-builder": "^22.7.0",
    "electron-rebuild": "^1.11.0"
  }
}
我在尝试后遇到的错误:npm运行postinstall

> install-app-deps

  • please use as subcommand: electron-builder install-app-deps
  • electron-builder  version=22.7.0
Error: Cannot compute electron version from installed node modules - none of the possible electron modules are installed.
See https://github.com/electron-userland/electron-builder/issues/3984#issuecomment-504968246
    at computeElectronVersion (C:\Users\boureima\Desktop\store_electron\node_modules\app-builder-lib\src\electron\electronVersion.ts:100:11)
    at getElectronVersion (C:\Users\boureima\Desktop\store_electron\node_modules\app-builder-lib\src\electron\electronVersion.ts:23:10)
    at async Promise.all (index 1)
    at installAppDeps (C:\Users\boureima\Desktop\store_electron\node_modules\electron-builder\src\cli\install-app-deps.ts:52:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! store_electron@1.0.0 postinstall: `install-app-deps`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the store_electron@1.0.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\boureima\AppData\Roaming\npm-cache\_logs\2020-06-04T10_37_40_435Z-debug.log
使用“postinstall”时:“electron builder安装应用程序deps”: 我明白了:

 ⨯ Cannot compute electron version from installed node modules - none of the possible electron modules are installed.
See https://github.com/electron-userland/electron-builder/issues/3984#issuecomment-504968246
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! store_electron@1.0.0 postinstall: ` electron-builder install-app-deps`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the store_electron@1.0.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\boureima\AppData\Roaming\npm-cache\_logs\2020-06-04T11_42_02_139Z-debug.log
请检查这篇文章

到目前为止,将SQLite与electron一起使用的最简单方法是使用electron builder

首先,在package.json中添加postinstall步骤

"scripts": {
   "postinstall": "electron-builder install-app-deps"
   ...
 }
"devDependencies": {
   "electron": "6.0.11",
   "electron-builder": "^21.2.0",
   ....
 }
然后安装必要的依赖项并生成:

npm install --save-dev electron-builder
npm install --save sqlite3
npm run postinstall

electron builder将为您的平台构建本机模块,并使用电子绑定的正确名称;然后你就可以像平常一样要求输入代码了。

我明白了⨯ 无法从已安装的节点模块计算electron版本-没有安装任何可能的electron模块请在package.json“electron”:“6.0.11”、“electron builder”:“^21.2.0”中尝试此操作,我不知道我已经共享了package.json。我的软件包中似乎没有electron。请使用“electron”更新您的设计附件:“6.0.11”,“electron builder”:“^21.2.0”,然后使用npm instal,然后再执行其他步骤。为什么版本为6.0.11和builder 21.2.0?这是否回答了您的问题?