Windows 中 Electron 的 SQLITE3 安装错误

SQLITE3 installation error for Electron in Windows

我正在尝试将 SQLITE3 与我的 Electron 应用程序一起使用,并最终使用 electron-packager 模块创建一个可执行文件。

我正在使用 --build-from-source 命令安装 sqlite3,因为 electron-rebuild 没有同时构建 sqlite3。下面是我的package.json

{
  "name": "dashboard",
  "version": "1.0.0",
  "main": "app/main.js",
  "scripts": {
    "start": "electron .",
    "package-win": "electron-packager . --overwrite --platform=win32 --arch=ia32 --icon=icons/win/icon.ico --prune=true --out=release-builds --version-string.CompanyName=CE --version-string.FileDescription=CE --version-string.ProductName=\"Serum Dashboard\""
  },
  "author": "Amar Shah",
  "license": "ISC",
  "dependencies": {
    "sqlite3": "^4.1.1"
  },
  "devDependencies": {
    "electron": "^7.1.10",
    "electron-packager": "^14.2.0"
  }
}

我执行了 windows-build-tools 并使用命令 npm install sqlite3 --build-from-source --runtime=electron --target=7.1.10 --dist-url=https://atom.io/download/electron --python=2.7

安装了 SQLITE3

虽然 运行,它给我以下错误


> sqlite3@4.1.1 install C:\serum-dashboard\node_modules\sqlite3
> node-pre-gyp install --fallback-to-build

node-pre-gyp WARN Using request for node-pre-gyp https download
Building the projects in this solution one at a time. To enable parallel build, please add the "/m" switch.
  unpack_sqlite_dep
  '2.7' is not recognized as an internal or external command,
  operable program or batch file.
C:\Program Files (x86)\Microsoft Visual Studio17\BuildTools\Common7\IDE\VC\VCTargets\Microsoft.CppCommon.targets(209,5): error MSB6006: "cmd.exe" exited with code 1. [C:\serum-dashboard\node_modules\
sqlite3\build\deps\action_before_build.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio17\BuildTools\MSBuild.0\Bin\MSBuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23)
gyp ERR! stack     at ChildProcess.emit (events.js:223:5)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "build" "--fallback-to-build" "--module=C:\serum-dashboard\node_modules\sqlite3\lib\binding\electron-v7.1-win32-x64\node_sqlite3.node" "--module_name=node_sqlite3" "--module_path=C:\serum-dashboard\node_modules\sqlite3\lib\binding\electron-v7.1-win32-x64" "--napi_version=5" "--node_abi_napi=napi" "--napi_build_version=0" "--node_napi_label=electron-v7.1"
gyp ERR! cwd C:\serum-dashboard\node_modules\sqlite3
gyp ERR! node -v v12.14.1
gyp ERR! node-gyp -v v5.0.5
gyp ERR! not ok

请帮我解决这个问题

你应该这样试试

"scripts": {
            "postinstall": "install-app-deps"
    }

我遇到了这个错误 unpack_sqlite_dep 'Python2.7' is not recognized as an internal or external command

我安装了 Python,并且在路径中。

我还安装了 MS 构建工具,但在节点中有一个配置设置使用与我之前不同版本的构建工具 - 我有 2017 年和现在的 2019 年,但在 npm 配置文件中它被设置使用 2015.

这是我在 AppData\Roaming\npm\etc 中找到的全局 npm 配置:
python=python3.9
msvs_version=2015

在您的用户文件夹中还有另一个本地位置。我从这两个文件中删除了 python 和 msvs 部分,现在可以使用了。

查看 npm 配置中的内容的有用命令:npm config list