简体   繁体   English

在Windows上为Electron App安装npm sqlite3

[英]Install npm sqlite3 on Windows for Electron App

I have a problem installing sqlite3 with npm in windows for an electron app. 我在电子应用程序的Windows中使用npm安装sqlite3和npm时遇到问题。 I installed sqlite3 with npm: 我用npm安装了sqlite3:

npm i sqlite3

Then I executed: 然后我执行了:

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

And I have this error: 我有这个错误:

× 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

Everything seems to indicate that it is the proxy, I have it configured well in .npmrc, but it does not work in this case, so I try to execute the command that launches electron-rebuild with the option --proxy: 一切似乎都表明它是代理,我在.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"

But then I have this error: 但是然后我有这个错误:

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"

It seems that it looks for a file named "binding.gyp" but it is not and I do not know where it should be or what it must have to work. 看起来它正在寻找一个名为“ binding.gyp”的文件,但实际上并非如此,我不知道它应该在哪里或必须要工作。

Some help? 一些帮助?

Thanks in advance. 提前致谢。

So, here are the steps that make it work: 因此,以下是使其工作的步骤:

First remove your node_modules folder and package-lock.json and follow below steps 首先删除您的node_modules文件夹和package-lock.json,然后执行以下步骤

install electron-rebuild 安装电子重建

npm install --save-dev electron-rebuild npm install --save-dev electronic-rebuild

install sqlite3 using npm 使用npm安装sqlite3

npm install --save sqlite3 npm install-保存sqlite3

rebuild electron with sqlite3. 用sqlite3重建电子。 In package.json scripts section, add: 在package.json脚本部分中,添加:

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

run the following command 运行以下命令

npm run rebuild npm运行重建

Now, you'll get another binding, something like: 现在,您将获得另一个绑定,例如:

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

which is accepted by electron. 被电子接受

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

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