使用电子构建sqlite3无效

时间:2017-11-12 11:18:31

标签: node.js npm electron

我尝试按照以下步骤使用SQlite数据库和电子应用程序:

1- npm install --save electron

2- npm install --save sqlite3

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

4- //添加重建并启动脚本到package.json

"start": "electron .",

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

5- npm run rebuild

但是它显示了一些错误:

    > 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

日志文件:

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 ]

我遵循了以下所有步骤: https://github.com/nodejs/node-gyp

3 个答案:

答案 0 :(得分:1)

安装Python 2.7并没有帮助,所以我安装了electron-builder

并在package.json "postinstall": "electron-builder install-app-deps"

中添加了一个新脚本。

因此,在安装sqlite之后,我安装了electronic builder并输入npm run postinstall

这为我解决了这个问题

答案 1 :(得分:0)

即使我遇到同样的问题。 请安装python 2.7版本并在Windows中将环境变量设置为C:\ Python27并再次使用电子重建。这次会工作。

答案 2 :(得分:0)

我最近不得不解决此问题,因为在引入sqlite3之后,我无法再在Mac上为Windows构建。为此,我必须使用VM(我使用Virtual Box)。以下是为了成功构建sqlite3而必须在VM上安装的所有软件的列表。

现在运行您的rebuild命令,希望一切顺利。

请注意,必须从VS 2017的Developers Command Prompt(开始菜单> Visual Studio 2017)中运行所有脚本,其中包含VS构建工具的所有必需环境路径 < / p>