繁体   English   中英

在Windows上为Electron App安装npm sqlite3

[英]Install npm sqlite3 on Windows for Electron App

我在电子应用程序的Windows中使用npm安装sqlite3和npm时遇到问题。 我用npm安装了sqlite3:

npm i sqlite3

然后我执行了:

.\node_modules\.bin\electron-rebuild.cmd

我有这个错误:

× Rebuild Failed

An unhandled error occurred inside electron-rebuild
gyp info it worked if it ends with ok
gyp info using node-gyp@3.8.0
gyp info using node@8.12.0 | win32 | x64
gyp http GET https://atom.io/download/electron/v2.0.10/iojs-v2.0.10.tar.gz
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: getaddrinfo EAI_AGAIN atom.io:443
gyp ERR! stack     at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:67:26)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\WindowsDev\\CopyWatcher\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--target=2.0.10" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source" "--module_name=node_sqlite3" "--module_path=D:\\WindowsDev\\CopyWatcher\\node_modules\\sqlite3\\lib\\binding\\electron-v2.0-win32-x64" "--host=https://mapbox-node-binary.s3.amazonaws.com" "--remote_path=./{name}/v4.0.2/{toolset}/" "--package_name=electron-v2.0-win32-x64.tar.gz"
gyp ERR! cwd D:\WindowsDev\CopyWatcher\node_modules\sqlite3
gyp ERR! node -v v8.12.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok

一切似乎都表明它是代理,我在.npmrc中对其进行了很好的配置,但是在这种情况下它不起作用,因此我尝试执行带有--proxy选项的启动电子重建的命令:

"C:\\Program Files\\nodejs\\node.exe" "D:\\WindowsDev\\CopyWatcher\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--target=2.0.10" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source" "--module_name=node_sqlite3" "--module_path=D:\\WindowsDev\\CopyWatcher\\node_modules\\sqlite3\\lib\\binding\\electron-v2.0-win32-x64" "--proxy=http://127.0.0.1:3131/" "--host=https://mapbox-node-binary.s3.amazonaws.com" "--remote_path=./{name}/v4.0.2/{toolset}/" "--package_name=electron-v2.0-win32-x64.tar.gz"

但是然后我有这个错误:

gyp: binding.gyp not found (cwd: D:\WindowsDev\CopyWatcher) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (D:\WindowsDev\CopyWatcher\node_modules\node-gyp\lib\configure.js:345:16)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:198:12)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\WindowsDev\\CopyWatcher\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--target=2.0.10" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source" "--module_name=node_sqlite3" "--module_path=D:\\\\WindowsDev\\\\CopyWatcher\\\\node_modules\\\\sqlite3\\\\lib\\\\binding\\\\electron-v2.0-win32-x64" "--proxy=http://127.0.0.1:3131/" "--host=https://mapbox-node-binary.s3.amazonaws.com" "--remote_path=./{name}/v4.0.2/{toolset}/" "--package_name=electron-v2.0-win32-x64.tar.gz"

看起来它正在寻找一个名为“ binding.gyp”的文件,但实际上并非如此,我不知道它应该在哪里或必须要工作。

一些帮助?

提前致谢。

因此,以下是使其工作的步骤:

首先删除您的node_modules文件夹和package-lock.json,然后执行以下步骤

安装电子重建

npm install --save-dev electronic-rebuild

使用npm安装sqlite3

npm install-保存sqlite3

用sqlite3重建电子。 在package.json脚本部分中,添加:

“ rebuild”:“电子重建-f -w sqlite3”

运行以下命令

npm运行重建

现在,您将获得另一个绑定,例如:

/.../node_modules/sqlite3/lib/binding/electron-v1.4-darwin-x64/node_sqlite3.node

被电子接受

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM