关于node.js:在Windows 10上为电子应用程序构建sqlite3

Build sqlite3 on windows 10 for electron app

我正在尝试在Windows 10上使用sqlite3数据存储创建一个简单的电子应用程序。

似乎由于某些node-gyp问题,我无法构建sqlite3。错误的堆栈跟踪。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
  ? rebuilding native production dependencies platform=win32 arch=x64
Error: C:\\Program Files\
odejs\
ode.exe exited with code 1
Output:

> [email protected] install C:\\Users\\Ilya\\puppy\
ode_modules\\sqlite3
> node-pre-gyp install --fallback-to-build

???????? ?????????? ?? ???? ? ?? ?襭??. ??? ??????? ????????? ???, ??????? ??????"/m".
MSBUILD : error MSB4025: ?? ????? ??????? ?? ????. ????????? ?????? ?????.
Failed to execute 'C:\\Program Files\
odejs\
ode.exe C:\\Program Files\
odejs\
ode_modules\
pm\
ode_modules\
ode-gyp\\bin\
ode-gyp.js build --fallback-to-build --module=C:\\Users\\Ilya\\puppy\
ode_modules\\sqlite3\\lib\\binding\\electron-v3.0-win32-x64\
ode_sqlite3.node --module_name=node_sqlite3 --module_path=C:\\Users\\Ilya\\puppy\
ode_modules\\sqlite3\\lib\\binding\\electron-v3.0-win32-x64 --napi_version=3 --node_abi_napi=napi' (1)

Error output:
node-pre-gyp WARN Using request for node-pre-gyp https download
node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.0.2/electron-v3.0-win32-x64.tar.gz
node-pre-gyp WARN Pre-built binaries not found for [email protected] and [email protected] (electron-v3.0 ABI, unknown) (falling back to source compile with node-gyp)
gyp ERR! build error
gyp ERR! stack Error: `msbuild` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\\Program Files\
odejs\
ode_modules\
pm\
ode_modules\
ode-gyp\\lib\\build.js:262: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_process.js:198:12)
gyp ERR! System Windows_NT 10.0.17134
gyp ERR! command"C:\\\\Program Files\\\
odejs\\\
ode.exe""C:\\\\Program Files\\\
odejs\\\
ode_modules\\\
pm\\\
ode_modules\\\
ode-gyp\\\\bin\\\
ode-gyp.js""build""--fallback-to-build""--module=C:\\\\Users\\\\Ilya\\\\puppy\\\
ode_modules\\\\sqlite3\\\\lib\\\\binding\\\\electron-v3.0-win32-x64\\\
ode_sqlite3.node""--module_name=node_sqlite3""--module_path=C:\\\\Users\\\\Ilya\\\\puppy\\\
ode_modules\\\\sqlite3\\\\lib\\\\binding\\\\electron-v3.0-win32-x64""--napi_version=3""--node_abi_napi=napi"
gyp ERR! cwd C:\\Users\\Ilya\\puppy\
ode_modules\\sqlite3
gyp ERR! node -v v8.11.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-pre-gyp ERR! build error
node-pre-gyp ERR! stack Error: Failed to execute 'C:\\Program Files\
odejs\
ode.exe C:\\Program Files\
odejs\
ode_modules\
pm\
ode_modules\
ode-gyp\\bin\
ode-gyp.js build --fallback-to-build --module=C:\\Users\\Ilya\\puppy\
ode_modules\\sqlite3\\lib\\binding\\electron-v3.0-win32-x64\
ode_sqlite3.node --module_name=node_sqlite3 --module_path=C:\\Users\\Ilya\\puppy\
ode_modules\\sqlite3\\lib\\binding\\electron-v3.0-win32-x64 --napi_version=3 --node_abi_napi=napi' (1)
node-pre-gyp ERR! stack     at ChildProcess. (C:\\Users\\Ilya\\puppy\
ode_modules\
ode-pre-gyp\\lib\\util\\compile.js:83:29)
node-pre-gyp ERR! stack     at emitTwo (events.js:126:13)
node-pre-gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
node-pre-gyp ERR! stack     at maybeClose (internal/child_process.js:925:16)
node-pre-gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
node-pre-gyp ERR! System Windows_NT 10.0.17134
node-pre-gyp ERR! command"C:\\\\Program Files\\\
odejs\\\
ode.exe""C:\\\\Users\\\\Ilya\\\\puppy\\\
ode_modules\\\
ode-pre-gyp\\\\bin\\\
ode-pre-gyp""install""--fallback-to-build"
node-pre-gyp ERR! cwd C:\\Users\\Ilya\\puppy\
ode_modules\\sqlite3
node-pre-gyp ERR! node -v v8.11.3
node-pre-gyp ERR! node-pre-gyp -v v0.10.3
node-pre-gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] install: `node-pre-gyp install --fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\\Users\\Ilya\\AppData\
oaming\
pm-cache\\_logs\\2018-10-07T18_17_21_376Z-debug.log

    at ChildProcess.childProcess.once.code (C:\\Users\\Ilya\\puppy\
ode_modules\\builder-util\\src\\util.ts:254:14)
    at Object.onceWrapper (events.js:317:30)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
From previous event:
    at rebuild (C:\\Users\\Ilya\\puppy\
ode_modules\\app-builder-lib\\out\\util\\yarn.js:239:18)
    at C:\\Users\\Ilya\\puppy\
ode_modules\\app-builder-lib\\src\\util\\yarn.ts:20:11
From previous event:
    at installOrRebuild (C:\\Users\\Ilya\\puppy\
ode_modules\\app-builder-lib\\out\\util\\yarn.js:68:17)
    at C:\\Users\\Ilya\\puppy\
ode_modules\\electron-builder\\src\\cli\\install-app-deps.ts:56:9
    at Generator.next ()
    at runCallback (timers.js:810:20)
    at tryOnImmediate (timers.js:768:5)
    at processImmediate [as _immediateCallback] (timers.js:745:5)
From previous event:
    at installAppDeps (C:\\Users\\Ilya\\puppy\
ode_modules\\electron-builder\\out\\cli\\install-app-deps.js:174:17)
    at main (C:\\Users\\Ilya\\puppy\
ode_modules\\electron-builder\\src\\cli\\install-app-deps.ts:65:10)
    at Object. (C:\\Users\\Ilya\\puppy\
ode_modules\\electron-builder\\src\\cli\\install-app-deps.ts:70:3)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Function.Module.runMain (module.js:693:10)
    at startup (bootstrap_node.js:191:16)
    at bootstrap_node.js:612:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `install-app-deps`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\\Users\\Ilya\\AppData\
oaming\
pm-cache\\_logs\\2018-10-07T18_17_21_461Z-debug.log

我尝试过的方法却无济于事:

  • 安装python2.7然后npm config set --python=C:\\path\\to\\python
  • npm install --global --production Windows构建工具
  • 以管理员身份运行npm install
  • 从VS2017控制台运行npm install
  • 更新npm和node-gyp版本
  • 删除我的节点模块并重新安装

都一样,我一直收到此错误。您是否有任何想法使sqlite3构建成为可能?

节点版本:8.11.3
NPM版本:5.6.0


我认为原因是[email protected]似乎与最近发布的[email protected]不兼容。查看日志时,您会发现下载相应的软件包失败:
node-pre-gyp WARN Tried to download(403): https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.0.2/electron-v3.0-win32-x64.tar.gz

相反,当您尝试在浏览器中打开https://mapbox-node-binary.s3.amazonaws.com/sqlite3/v4.0.2/electron-v2.0-win32-x64.tar.gz时,它将起作用。

我目前正在发现相同的问题。使用较旧版本的电子对我有效。我的package.json看起来像这样:
"sqlite3":"^4.0.2",
...
"electron":"2.0.7",
"electron-builder":"20.28.1",

希望有帮助!

更新:几天前[email protected]已发布。这个版本解决了这个问题,现在可以与[email protected]一起使用。我的依赖项现在看起来像这样:
"sqlite3":"^4.0.3",
...
"electron":"3.0.6",
"electron-builder":"20.28.4",