Windows 下的 electron 编译常见问题

2021-01-14 14:13

阅读:435

标签:sar   build   complete   intern   util   events   modules   writable   download   

Windows系统编译

下载安装:
node v9.8.0
yarn-1.9.4
安装windows编译工具

npm install --global windows-build-tools

安装项目依赖

yarn install

开始编译,打包

npm run build
npm run release-win

常见错误

iojs.lib : fatal error LNK1106

c:\users\surou\desktop\scatterdesktop\node_modules\keccak\src\libkeccak\KeccakSponge.h : warning C4819: ??????????????????????(936)?б????????????????????? Unicode ????????????? (???????? ..\src\libkeccak\KeccakSponge.c) [C:\Users\Surou\Desktop\ScatterDesktop\node_modules\keccak\build\keccak.vcxproj]
C:\Users\Surou\.electron-gyp\.node-gyp\iojs-2.0.11\x64\iojs.lib : fatal error LNK1106: ?????Ч?????????: ???????? 0x29851C [C:\Users\Surou\Desktop\ScatterDesktop\node_modules\keccak\build\keccak.vcxproj]
gyp ERR! build error
gyp ERR! stack Error: `C:\Program Files (x86)\MSBuild\14.0\bin\msbuild.exe` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onExit (C:\Users\Surou\Desktop\ScatterDesktop\node_modules\node-gyp\lib\build.js:262:23)
gyp ERR! stack     at ChildProcess.emit (events.js:180:13)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:209:12)
gyp ERR! System Windows_NT 10.0.16299
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\Surou\\Desktop\\ScatterDesktop\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--target=2.0.11" "--arch=x64" "--dist-url=https://atom.io/download/electron" "--build-from-source"
gyp ERR! cwd C:\Users\Surou\Desktop\ScatterDesktop\node_modules\keccak
gyp ERR! node -v v9.8.0
gyp ERR! node-gyp -v v3.8.0

解决方案:删除 C:\Users\Surou\.electron-gyp
参考:https://github.com/electron/electron-rebuild/issues/163
app-builder.exe exited with code 1

Error: C:\Users\Surou\Desktop\ScatterDesktop\node_modules\app-builder-bin\win\x64\app-builder.exe exited with code 1
  at ChildProcess.childProcess.once.code (C:\Users\Surou\Desktop\ScatterDesktop\node_modules\builder-util\src\util.ts:254:14)
  at Object.onceWrapper (events.js:272:13)
  at ChildProcess.emit (events.js:180:13)
  at maybeClose (internal/child_process.js:936:16)
  at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)

解决方案:删除node_modules,重新yarn install
参考:https://github.com/electron-userland/electron-builder/issues/2002
.bin\babylon: Error: ENOENT: no such file or directory

Cannot read file C:\Users\Surou\Desktop\ScatterDesktop\node_modules\babylon\.bin\babylon: Error: ENOENT: no such file or directory, open 'C:\Users\Surou\Desktop\ScatterDesktop\node_modules\babylon\.bin\babylon'
  at w (C:\Users\Surou\Desktop\ScatterDesktop\node_modules\app-builder-lib\src\asar\asarUtil.ts:201:11)
  at writeStream.write (C:\Users\Surou\Desktop\ScatterDesktop\node_modules\app-builder-lib\src\asar\asarUtil.ts:203:43)
  at afterWrite (_stream_writable.js:473:3)
  at onwrite (_stream_writable.js:464:7)
  at fs.write (fs.js:2252:5)-win: `electron-builder --win`
  at FSReqWrap.wrapper [as oncomplete] (fs.js:707:5)

解决方案:安装yarn-1.9.4版本
参考:https://github.com/GetScatter/ScatterDesktop/issues/165
编译完,运行,界面空白
经过反编译app.asar,发现缺少dist
解决方案:先运行npm run build,在运行npm run release-win

其他

反编译asar

npm install -g asar
asar extract app.asar ./

关联

https://www.bcskill.com/index.php/archives/476.html

Windows 下的 electron 编译常见问题

标签:sar   build   complete   intern   util   events   modules   writable   download   

原文地址:https://www.cnblogs.com/juwan/p/12255653.html


评论


亲,登录后才可以留言!