Repository navigation
I couldn't build successfully in electron #1746
Description
Issue Summary
I have used sqlite3 in electron, which can be successfully dev, but the following error will be reported during build. I don't know how I should solve this problem, so I would like to ask if anyone can help me solve this problem.
The related dependency versions I use are as follows:
The sqlite3 version is 5.1.7,
The node-gyp version is 8.4.1.
The node version is 16.18.0.
The yarn version is 1.22.21
Relevant logs or output
yarn run v1.22.21
$ vue-tsc --noEmit && vite build && electron-builder
[unplugin-vue-components] component "Basic"(D:/work/xxx/xxx/src/components/SyncProgress/src/Basic.vue) has naming conflicts with other components, ignored.
vite v4.5.1 building for production...
node_modules/easemob-websdk/miniCore/miniCore.js (1:7237) Use of eval in "node_modules/easemob-websdk/miniCore/miniCore.js" is strongly discouraged as it poses security risks and may cause issues with minification.
node_modules/easemob-websdk/Easemob-chat.js (1:7237) Use of eval in "node_modules/easemob-websdk/Easemob-chat.js" is strongly discouraged as it poses security risks and may cause issues with minification.
✓ 1771 modules transformed.
dist/index.html 0.55 kB │ gzip: 0.40 kB
dist/assets/head2-58730d9e.jpg 4.94 kB
dist/assets/iconfont-f83ad384.ttf 5.21 kB
dist/assets/iconfont-43aa91a6.eot 5.38 kB
dist/assets/head3-8654d57e.jpg 8.01 kB
dist/assets/head1-44e62e25.jpg 8.23 kB
dist/assets/head-91484c92.jpg 9.90 kB
dist/assets/iconfont-0f08d651.svg 17.06 kB │ gzip: 6.11 kB
dist/assets/login-e2a4b4ad.png 247.52 kB
dist/assets/index-e066774d.css 0.15 kB │ gzip: 0.14 kB
dist/assets/PullPerson-1f2a124e.css 0.22 kB │ gzip: 0.14 kB
dist/assets/SingleChat-0bc457f9.css 0.30 kB │ gzip: 0.18 kB
dist/assets/SelfChatList-f581c094.css 0.52 kB │ gzip: 0.32 kB
dist/assets/index-9e7f23c0.css 0.82 kB │ gzip: 0.38 kB
dist/assets/BacklogList-a1abf7d2.css 1.49 kB │ gzip: 0.44 kB
dist/assets/el-radio-94b07b0d.css 4.39 kB │ gzip: 0.99 kB
dist/assets/GroupChat-1efd6e54.css 43.83 kB │ gzip: 5.22 kB
dist/assets/index-19300c20.css 379.31 kB │ gzip: 59.42 kB
dist/assets/index-72bdf85a.js 0.49 kB │ gzip: 0.35 kB
dist/assets/index-687f6d70.js 0.81 kB │ gzip: 0.56 kB
dist/assets/BacklogList-9596c239.js 1.65 kB │ gzip: 0.90 kB
dist/assets/PullPerson-d942f364.js 2.62 kB │ gzip: 1.35 kB
dist/assets/SelfChatList-07907cbf.js 3.26 kB │ gzip: 1.65 kB
dist/assets/SingleChat-05682c53.js 5.31 kB │ gzip: 2.49 kB
dist/assets/el-radio-52869d58.js 18.88 kB │ gzip: 7.49 kB
dist/assets/GroupChat-4045fd19.js 24.87 kB │ gzip: 7.58 kB
dist/assets/index-4b322429.js 2,015.87 kB │ gzip: 572.97 kB
(!) Some chunks are larger than 500 kBs after minification. Consider:
- Using dynamic import() to code-split the application
- Use build.rollupOptions.output.manualChunks to improve chunking: https://rollupjs.org/configuration-options/#output-manualchunks
- Adjust chunk size limit for this warning via build.chunkSizeWarningLimit.
✓ built in 11.66s
vite v4.5.1 building for production...
✓ 21 modules transformed.
dist-electron/main/index.js 0.17 kB │ gzip: 0.11 kB
dist-electron/main/index-17415e26.js 1.27 kB │ gzip: 0.64 kB
dist-electron/main/index-17e8c2e0.js 2.52 kB │ gzip: 1.02 kB
dist-electron/main/index-1dff5a59.js 10.02 kB │ gzip: 4.11 kB
✓ built in 95ms
vite v4.5.1 building for production...
✓ 8 modules transformed.
dist-electron/preload/index.js 4.06 kB │ gzip: 1.59 kB
✓ built in 29ms
• electron-builder version=24.9.1 os=10.0.19044
• loaded configuration file=D:\work\xxx\electron-builder.json5
• @electron/rebuild not required if you use electron-builder, please consider to remove excess dependency from devDependencies
To ensure your native dependencies are always matched electron version, simply add script "postinstall": "electron-builder install-app-deps" to your package.json`
• writing effective config file=release\1.0.0\builder-effective-config.yaml
• rebuilding native dependencies [email protected] platform=win32 arch=x64
• install prebuilt binary name=sqlite3 version=5.1.7 platform=win32 arch=x64 napi=
• build native dependency from sources name=sqlite3
version=5.1.7
platform=win32
arch=x64
napi=
reason=prebuild-install failed with error (run with env DEBUG=electron-builder to get more information)
error=prebuild-install info begin Prebuild-install version 7.1.1
prebuild-install warn This package does not support N-API version 36
prebuild-install warn install prebuilt binaries enforced with --force!
prebuild-install warn install prebuilt binaries may be out of date!
prebuild-install info looking for local prebuild @ prebuilds\sqlite3-v5.1.7-napi-v36-win32-x64.tar.gz
prebuild-install info looking for cached prebuild @ C:\Users\user\AppData\Roaming\npm-cache_prebuilds\9aa761-sqlite3-v5.1.7-napi-v36-win32-x64.tar.gz
prebuild-install http request GET https://github.com/TryGhost/node-sqlite3/releases/download/v5.1.7/sqlite3-v5.1.7-napi-v36-win32-x64.tar.gz
prebuild-install warn install connect ETIMEDOUT 20.205.243.166:443
• rebuilding native dependency name=sqlite3 version=5.1.7
⨯ cannot execute cause=exit status 1
$ prebuild-install -r napi || node-gyp rebuild
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
errorOut=prebuild-install warn This package does not support N-API version 27.2.1
prebuild-install warn install connect ETIMEDOUT 20.205.243.166:443
gyp info it worked if it ends with ok
gyp info using [email protected]
gyp info using [email protected] | win32 | x64
gyp info find Python using Python version 3.6.7 found at "C:\Users\user\AppData\Local\Programs\Python\Python36-32\python.exe"
gyp info find VS using VS2019 (16.11.34301.259) found at:
gyp info find VS "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools"
gyp info find VS run with --verbose for detailed information
gyp info spawn C:\Users\user\AppData\Local\Programs\Python\Python36-32\python.exe
gyp info spawn args [
gyp info spawn args 'D:\\work\\xxx\\node_modules\\node-gyp\\gyp\\gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'msvs',
gyp info spawn args '-I',
gyp info spawn args 'D:\\work\\xxx\\node_modules\\sqlite3\\build\\config.gypi',
gyp info spawn args '-I',
gyp info spawn args 'D:\\work\\xxx\\node_modules\\node-gyp\\addon.gypi',
gyp info spawn args '-I',
gyp info spawn args 'C:\\Users\\user\\.electron-gyp\\27.2.1\\include\\node\\common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=C:\\Users\\user\\.electron-gyp\\27.2.1',
gyp info spawn args '-Dnode_gyp_dir=D:\\work\\xxx\\node_modules\\node-gyp',
gyp info spawn args '-Dnode_lib_file=C:\\\\Users\\\\user\\\\.electron-gyp\\\\27.2.1\\\\<(target_arch)\\\\node.lib',
gyp info spawn args '-Dmodule_root_dir=D:\\work\\xxx\\node_modules\\sqlite3',
gyp info spawn args '-Dnode_engine=v8',
gyp info spawn args '--depth=.',
gyp info spawn args '--no-parallel',
gyp info spawn args '--generator-output',
gyp info spawn args 'D:\\work\\xxx\\node_modules\\sqlite3\\build',
gyp info spawn args '-Goutput_dir=.'
gyp info spawn args ]
Traceback (most recent call last):
File "D:\work\xxx\node_modules\node-gyp\gyp\gyp_main.py", line 45, in <module>
sys.exit(gyp.script_main())
File "D:\work\xxx\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 662, in script_main
return main(sys.argv[1:])
File "D:\work\xxx\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 654, in main
return gyp_main(args)
File "D:\work\xxx\node_modules\node-gyp\gyp\pylib\gyp\__init__.py", line 639, in gyp_main
generator.GenerateOutput(flat_list, targets, data, params)
File "D:\work\xxx\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 2140, in GenerateOutput
_GenerateProject(project, options, msvs_version, generator_flags, spec)
File "D:\work\xxx\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 1027, in _GenerateProject
return _GenerateMSBuildProject(project, options, version, generator_flags, spec)
File "D:\work\xxx\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 3738, in _GenerateMSBuildProject
toolset,
File "D:\work\xxx\node_modules\node-gyp\gyp\pylib\gyp\generator\msvs.py", line 2219, in _GenerateMSBuildFiltersFile
easy_xml.WriteXmlIfChanged(content, filters_path, pretty=True, win32=True)
File "D:\work\xxx\node_modules\node-gyp\gyp\pylib\gyp\easy_xml.py", line 131, in WriteXmlIfChanged
existing = file.read()
UnicodeDecodeError: 'gbk' codec can't decode byte 0xb7 in position 815: illegal multibyte sequence
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack at ChildProcess.onCpExit (D:\work\xxx\node_modules\node-gyp\lib\configure.js:259:16)
gyp ERR! stack at ChildProcess.emit (node:events:513:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:293:12)
gyp ERR! System Windows_NT 10.0.19044
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\work\\xxx\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd D:\work\xxx\node_modules\sqlite3
gyp ERR! node -v v16.18.0
gyp ERR! node-gyp -v v8.4.1
gyp ERR! not ok
error Command failed with exit code 1.
command='C:\Program Files\nodejs\node.exe' 'C:\Users\user\AppData\Roaming\nvm\v16.18.0\node_modules\yarn\bin\yarn.js' run install
workingDir=D:\work\xxx\node_modules\sqlite3
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
Version
5.1.7
Node.js Version
16.18.0
How did you install the library?
yarn add sqlite3
Activity
qyn980427 commentedon Jan 5, 2024
The electron version is 27.1.0
JOJO-Or2 commentedon Jan 5, 2024
Mee too. But the electron version is 9.3.3.
BernhardBehrendt commentedon Jan 5, 2024
My electron app build also starts complaining.
spamshaker commentedon Jan 7, 2024
same here. I have temp workaround
pnpm --prefix=node_modules/sqlite3 run rebuildor also works for me
(cd $(dirname $(node -p 'require.resolve(sqlite3/package.json)')) && pnpx prebuild-install -r napi --verbose)or
(cd $(dirname $(node -p 'require.resolve(sqlite3/package.json)')) && npx prebuild-install -r napi --verbose)however that sounds like thing related to cache. When removed the cache it has been rebuild and more ore less started working (can't check with @electron/rebuild now but i guess it may work now)
https://github.com/prebuild/prebuild-install/blob/master/README.md#cache
I also noticed that node 18 has napi 9 so the requested target v36 might be a clue of the issue
the issue seems to be with one of legacy dependencies of electron-builder. I reported a bug there
liyang9331 commentedon Jan 15, 2024
me too!How did you solve it
kamuridesu commentedon Jan 17, 2024
@liyang9331
Workaround: use 5.1.6 instead of 5.1.7
#1748 (comment)
ADumaine commentedon Jan 24, 2024
I ran into the same issue trying to install 5.1.7. Installing 5.1.6 instead works builds with no issue.
npm install -E [email protected]
Running node v20.9.0 on my win 10 system, building with electron v28.1.4 and electron-builder v24.9.1
section of the output with env var "DEBUG=electron-builder"
pinned sqlite3 dependency for electron builds to version 5.1.6 becaus…
cempack commentedon Mar 3, 2024
Same here, this worked for me
hearRaing commentedon Mar 18, 2024
I also encountered the same problem, why is the N-API version 36 instead of the specific version?
draungminoo commentedon Mar 25, 2024
I have the same issue.
npm install -E [email protected]
This really solves for me. Thanks. @ADumaine
aehyok commentedon Mar 27, 2024
@draungminoo Thank you so much
r-minhan commentedon Apr 23, 2024
@draungminoo Thank you~!
mundane799699 commentedon Apr 30, 2024
me too.revert to 5.1.6 is ok.
Asuancaiyu commentedon May 2, 2024
我有一个不降低版本的做法:
sqlite3-v5.1.7-napi-v6-win32-x64.tar.gz改为sqlite3-v5.1.7-napi-v36-win32-x64.tar.gz。prebuilds目录(当然也可以是其他任何地方)。.npmrc文件,文件内容如下:prebuilds目录下, 文件目录结构如下pnpm buildyubaoquan commentedon May 2, 2024
same here. I guess something is wrong with version detecting logic, it is supposed to return 3 or 6, not 36
wenjoy commentedon May 6, 2024
I revert to 5.1.6 got below error, anyone with me?
pranavwani commentedon May 22, 2024
This one works:
phuonghuynh commentedon Jun 22, 2024
Jump in this issue today, my fix are:
alisherafat01 commentedon Jul 22, 2024
I have the same error even with 5.1.6 version :(
renjietan commentedon Jul 29, 2024
在windows中 为什么我指定了路径 无效
collinsyu commentedon Dec 31, 2024
大佬接受膜拜
Wyatth7 commentedon Apr 3, 2025
@kamuridesu You are a life-saver. You have no idea how long I was on this.
yueisme commentedon Apr 8, 2025
Xavier9896 commentedon May 1, 2025
我暂时是这么解决的:添加一个脚本,在 build 脚本前执行
I temporarily solved it this way: add a script and execute it before the build script
fix: attempt to fix based on TryGhost/node-sqlite3/issues/1746