简体   繁体   English

用电子建立sqlite3不起作用

[英]build sqlite3 with electron is not working

I'm trying to use SQlite database with electron app by following these steps: 我正在尝试通过以下步骤将SQlite数据库与电子应用程序一起使用:

1- npm install --save electron 1- npm安装-保存电子

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

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

4- //add rebuild and start script to package.json 4- //将重建和启动脚本添加到package.json

"start": "electron .",

"rebuild": "electron-rebuild -f -w sqlite3",

5- npm run rebuild 5- npm运行重建

but it's show some errors: 但显示出一些错误:

    > sql3@1.0.0 rebuild C:\Users\wnw\projs\sql3
> electron-rebuild -f -w sqlite3

? Rebuild Failed

An unhandled error occurred inside electron-rebuild
Building the projects in this solution one at a time. To enable parallel build,
please add the "/m" switch.
  unpack_sqlite_dep
  'python' is not recognized as an internal or external command,
  operable program or batch file.
C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171
,5): error MSB6006: "cmd.exe" exited with code 1. [C:\Users\wnw\projs\sql3\node_
modules\sqlite3\build\deps\action_before_build.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files\MSBuild\14.0\bin\msbuild.exe` failed wit
h exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\wnw\projs\sql3\node_modules\
node-gyp\lib\build.js:258:23)
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_proces
s.js:198:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\wnw\\projs\\s
ql3\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--target=1.4.13" "--ar
ch=ia32" "--dist-url=https://atom.io/download/electron" "--build-from-source" "-
-module_name=node_sqlite3" "--module_path=C:\\Users\\wnw\\projs\\sql3\\node_modu
les\\sqlite3\\lib\\binding\\electron-v1.4-win32-ia32" "--host=https://mapbox-nod
e-binary.s3.amazonaws.com" "--remote_path=./{name}/v3.1.13/{toolset}/" "--packag
e_name=electron-v1.4-win32-ia32.tar.gz"
gyp ERR! cwd C:\Users\wnw\projs\sql3\node_modules\sqlite3
gyp ERR! node -v v8.9.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok

Failed with exit code: 1

Error: Building the projects in this solution one at a time. To enable parallel
build, please add the "/m" switch.
  unpack_sqlite_dep
  'python' is not recognized as an internal or external command,
  operable program or batch file.
C:\Program Files\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171
,5): error MSB6006: "cmd.exe" exited with code 1. [C:\Users\wnw\projs\sql3\node_
modules\sqlite3\build\deps\action_before_build.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files\MSBuild\14.0\bin\msbuild.exe` failed wit
h exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\wnw\projs\sql3\node_modules\
node-gyp\lib\build.js:258:23)
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_proces
s.js:198:12)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\wnw\\projs\\s
ql3\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--target=1.4.13" "--ar
ch=ia32" "--dist-url=https://atom.io/download/electron" "--build-from-source" "-
-module_name=node_sqlite3" "--module_path=C:\\Users\\wnw\\projs\\sql3\\node_modu
les\\sqlite3\\lib\\binding\\electron-v1.4-win32-ia32" "--host=https://mapbox-nod
e-binary.s3.amazonaws.com" "--remote_path=./{name}/v3.1.13/{toolset}/" "--packag
e_name=electron-v1.4-win32-ia32.tar.gz"
gyp ERR! cwd C:\Users\wnw\projs\sql3\node_modules\sqlite3
gyp ERR! node -v v8.9.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok

Failed with exit code: 1
    at SafeSubscriber._error (C:\Users\wnw\projs\sql3\node_modules\spawn-rx\lib\
src\index.js:277:84)
    at SafeSubscriber.__tryOrUnsub (C:\Users\wnw\projs\sql3\node_modules\rxjs\Su
bscriber.js:238:16)
    at SafeSubscriber.error (C:\Users\wnw\projs\sql3\node_modules\rxjs\Subscribe
r.js:197:26)
    at Subscriber._error (C:\Users\wnw\projs\sql3\node_modules\rxjs\Subscriber.j
s:128:26)
    at Subscriber.error (C:\Users\wnw\projs\sql3\node_modules\rxjs\Subscriber.js
:102:18)
    at MapSubscriber.Subscriber._error (C:\Users\wnw\projs\sql3\node_modules\rxj
s\Subscriber.js:128:26)
    at MapSubscriber.Subscriber.error (C:\Users\wnw\projs\sql3\node_modules\rxjs
\Subscriber.js:102:18)
    at SafeSubscriber._next (C:\Users\wnw\projs\sql3\node_modules\spawn-rx\lib\s
rc\index.js:251:65)
    at SafeSubscriber.__tryOrSetError (C:\Users\wnw\projs\sql3\node_modules\rxjs
\Subscriber.js:247:16)
    at SafeSubscriber.next (C:\Users\wnw\projs\sql3\node_modules\rxjs\Subscriber
.js:187:27)
npm ERR! code ELIFECYCLE
npm ERR! errno 4294967295
npm ERR! sql3@1.0.0 rebuild: `electron-rebuild -f -w sqlite3`
npm ERR! Exit status 4294967295
npm ERR!
npm ERR! Failed at the sql3@1.0.0 rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\wnw\AppData\Roaming\npm-cache\_logs\2017-11-12T11_04_58_33
3Z-debug.log

the log file: 日志文件:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\wnw\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'rebuild' ]
2 info using npm@5.5.1
3 info using node@v8.9.1
4 verbose run-script [ 'prerebuild', 'rebuild', 'postrebuild' ]
5 info lifecycle sql3@1.0.0~prerebuild: sql3@1.0.0
6 info lifecycle sql3@1.0.0~rebuild: sql3@1.0.0
7 verbose lifecycle sql3@1.0.0~rebuild: unsafe-perm in lifecycle true
8 verbose lifecycle sql3@1.0.0~rebuild: PATH: C:\Users\wnw\AppData\Roaming\npm\node_modules\npm\bin\node-gyp-bin;C:\Users\wnw\projs\sql3\node_modules\.bin;C:\ProgramData\Oracle\Java\javapath;C:\Program Files\NVIDIA Corporation\PhysX\Common;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files\Intel\OpenCL SDK\2.0\bin\x86;C:\Program Files\Intel\OpenCL SDK\2.0\bin\x86;C:\Users\wnw\AppData\Local\Android\sdk\platform-tools;C:\Program Files\Git\cmd;C:\Program Files\Brackets\command;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\110\Tools\Binn\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\;C:\Program Files\Microsoft SQL Server\120\DTS\Binn\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\AppServ\php5;C:\Users\wnw\AppData\Roaming\npm;C:\Program Files\WinAnt\bin;C:\Program Files\Git;C:\adb;C:\Program Files\MySQL\MySQL Utilities 1.6\;C:\Program Files\nodejs\;C:\Program Files\Common Files\Microsoft Shared\Windows Live;C:\AppServ\php5;C:\Program Files\WinAnt\bin;C:\Program Files\Git;C:\Users\wnw\AppData\Roaming\npm
9 verbose lifecycle sql3@1.0.0~rebuild: CWD: C:\Users\wnw\projs\sql3
10 silly lifecycle sql3@1.0.0~rebuild: Args: [ '/d /s /c', 'electron-rebuild -f -w sqlite3' ]
11 silly lifecycle sql3@1.0.0~rebuild: Returned: code: 4294967295  signal: null
12 info lifecycle sql3@1.0.0~rebuild: Failed to exec rebuild script
13 verbose stack Error: sql3@1.0.0 rebuild: `electron-rebuild -f -w sqlite3`
13 verbose stack Exit status 4294967295
13 verbose stack     at EventEmitter.<anonymous> (C:\Users\wnw\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:280:16)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at EventEmitter.emit (events.js:214:7)
13 verbose stack     at ChildProcess.<anonymous> (C:\Users\wnw\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:126:13)
13 verbose stack     at ChildProcess.emit (events.js:214:7)
13 verbose stack     at maybeClose (internal/child_process.js:925:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid sql3@1.0.0
15 verbose cwd C:\Users\wnw\projs\sql3
16 verbose Windows_NT 6.1.7601
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\wnw\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "rebuild"
18 verbose node v8.9.1
19 verbose npm  v5.5.1
20 error code ELIFECYCLE
21 error errno 4294967295
22 error sql3@1.0.0 rebuild: `electron-rebuild -f -w sqlite3`
22 error Exit status 4294967295
23 error Failed at the sql3@1.0.0 rebuild script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 4294967295, true ]

I followed all these steps: https://github.com/nodejs/node-gyp 我遵循了所有这些步骤: https : //github.com/nodejs/node-gyp

I recently had to solve this issue as I could no longer build for Windows on my Mac after introducing sqlite3. 最近,我不得不解决此问题,因为在引入sqlite3之后,我无法再在Mac上为Windows构建。 I had to use a VM for this (I used Virtual Box). 为此,我必须使用VM(我使用Virtual Box)。 Below is a list of all the software I had to install on the VM in order to successfully build sqlite3. 以下是我为了成功构建sqlite3而必须在VM上安装的所有软件的列表。

Now run your rebuild command and hopefully all is well. 现在运行您的rebuild命令,希望一切顺利。

Please note, execution of all scripts must be run from the Developers Command Prompt for VS 2017 (Start Menu > Visual Studio 2017), which contains all the necessary environment paths to the VS build tools 请注意,必须从VS 2017的Developers Command Prompt(开始菜单> Visual Studio 2017)中运行所有脚本,该脚本包含VS构建工具的所有必要环境路径。

Installing Python 2.7 didn't help so I installed electron-builder 安装Python 2.7并没有帮助,所以我安装了electronic-builder

and added a new script in the package.json "postinstall": "electron-builder install-app-deps" 并在package.json "postinstall": "electron-builder install-app-deps"添加了一个新脚本"postinstall": "electron-builder install-app-deps"

so after installing sqlite I install electron builder and type npm run postinstall 所以在安装sqlite之后,我安装了electronic builder并输入npm run postinstall

this solved the issue for me 这为我解决了这个问题

Even I faced the same issue. 即使我也面临同样的问题。 Please install python 2.7 version and set the environment variable to C:\\Python27 in windows and try again with electron rebuild.It will work this time. 请安装python 2.7版本,然后在Windows中将环境变量设置为C:\\ Python27,然后重试电子重建功能。

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

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