8.4.0版本 Mac
删除Cache还是升级了Mixin。 0.10.2版本Mac上需要electron的8.4版本 cat yarn.lock | grep electron
Mac上出现跟Windows上类似的情况。需要手动下载https://github.com/electron/electron/releases/tag/v8.4.0
的electron-v8.4.0-darwin-x64.zip
,然后解压到项目的 node_modules/electron/disk
目录下。
手动创建path.txt
文件,内容添加未 Electron.app/Contents/MacOS/Electron
,第一开始只写了Electron.app
是无效的。后面安装了一个全局的Electron参考了对应的path.txt
里的写法。
但依然报错——
INFO Launching Electron...
(node:55762) UnhandledPromiseRejectionWarning: Error: spawn /Users/gebitang/projects/github/desktop-app/node_modules/electron/dist/Electron.app/Contents/MacOS/Electron
ENOENT
at Process.ChildProcess._handle.onexit (internal/child_process.js:264:19)
at onErrorNT (internal/child_process.js:456:16)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
(node:55762) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 2)
(node:55762) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
有说是$PATH问题 添加了PATH路径后,问题依旧;
官方#39针对的是windows环境下的问题。
直接启动安装的Electron,验证是否正确安装。应用正常启动,到包含了类似的报错——
Reading /Users/gebitang/projects/project-desktop/uitest-desktop/node_modules/devtron/manifest.json failed.
Error: ENOENT: no such file or directory, open '/Users/gebitang/projects/project-desktop/uitest-desktop/node_modules/devtron/manifest.json'
at Object.openSync (fs.js:440:3)
at Object.func [as openSync] (electron/js2c/asar.js:140:31)
at Object.readFileSync (fs.js:342:35)
at Object.fs.readFileSync (electron/js2c/asar.js:542:40)
at getManifestFromPath (electron/js2c/browser_init.js:4124:26)
at Function.BrowserWindow.addExtension (electron/js2c/browser_init.js:4546:22)
at Function.BrowserWindow.addDevToolsExtension (electron/js2c/browser_init.js:4578:40)
at App.<anonymous> (electron/js2c/browser_init.js:4607:23)
at Object.onceWrapper (events.js:300:26)
at App.emit (events.js:215:7)
有类似的问题,删除~/Library/Application Support/Electron/DevTools Extensions
文件之后,上述问题消失。但使用 yarn electron:serve
时依然复现相同的问题。
按照index.js
的要求,导出ELECTRON_OVERRIDE_DIST_PATH
的值(官方教程:变量使用),还是不行。
先卸载,再手动使用npm安装npm install electron@^v8.4.0
。实际上安装的为8.4.1
版本,内网和淘宝的registry都没有速度,挂上代理,使用npm --registry https://registry.npm.taobao.org install
安装成功。
应用可以成功启动,但提示编译的版本不对。重新执行 yarn install
之后,再启动应用。成功。
还是没看出来哪里导致的问题。难不成是8.4.0版本有bug乜:(
8.3.0版本
哈哈,我这个应该叫做跟着Mixin学Node乜。今天升级到0.9.6版本后启动遇到点小问题。node-gyp
和electron
安装问题
- yarn执行安装失败。
node-gyp
的安装应该需要翻墙。使用代理后的CMD窗口后编译正常。
用来进行交叉编译的?可以进行全局安装一下?之前搭建STF环境时也遇到过这个问题。
node-gyp
is a cross-platform command-line tool written in Node.js for compiling native addon modules for Node.js. It contains a fork of the gyp project that was previously used by the Chromium team, extended to support the development of Node.js native addons.Note that
node-gyp
is not used to build Node.js itself.
> node-gyp rebuild --release
D:\openSources\mixin\desktop-app\node_modules\better-sqlite3>if not defined npm_config_node_gyp (node "D:\tools\nvmm\v12.11.1\node_modules\npm\node_modules\npm-lifecycle\no
yp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild --release ) else (node "D:\tools\nvmm\v12.11.1\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" rebuild
lease )
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
errorOut=prebuild-install WARN install No prebuilt binaries found (target=8.3.0 runtime=electron arch=x64 libc= platform=win32)
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: read ECONNRESET
gyp ERR! stack at TLSWrap.onStreamRead (internal/stream_base_commons.js:201:27)
gyp ERR! System Windows_NT 10.0.18363
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\tools\\nvmm\\v12.11.1\\node_modules\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--release"
gyp ERR! cwd D:\openSources\mixin\desktop-app\node_modules\better-sqlite3
gyp ERR! node -v v12.11.1
gyp ERR! node-gyp -v v5.0.3
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! better-sqlite3@7.0.1 build-release: `node-gyp rebuild --release`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the better-sqlite3@7.0.1 build-release script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
- 启动再次遇到Electron问题
应该是yarn重新编译时将我之前手动安装的8.2.5版本清理了。最新版本根据yarn.lock
文件看升级到了8.3.0
版本。对应的判断逻辑也做了优化。
轻车熟路,手动下载8.3.0
版本,解压到electron模块的dist
文件夹,新建path.txt
文件,内容写入electron.exe
。启动成功。
Node看起来会默认自动检查dist目录。第一次写入dist\electron.exe
的内容,启动报错UnhandledPromiseRejectionWarning spawn D:\openSources\mixin\desktop-app\node_modules\electron\dist\dist\electron.exe
D:\openSources\mixin\desktop-app\node_modules\electron\index.js:14
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
^
...
8.2.5版本
Electron failed to install correctly, please delete node_modules/electron and try installing again
安装了多次,总是提示上面的错误。在Mac环境下是正常的。因为懒惰&恐惧的原因,一直没有正面强攻解决问题。尝试重新安装,清除仓库从头安装,都无疾而终。
- Create a file named path.txt in node_modules\electron folder.
- Write electron.exe in it.
- Download electron package manualy.
- Unpackage the electron files into node_modules\electron\dist
- Run your start script
看看源码+对比Mac环境下的内容:
首先是缺少path.txt
文件。这样至少可以试试上面的解决方案。
throw new Error('Electron failed to install correctly, please delete node_modules/electron and try installing again')
^
Error: Electron failed to install correctly, please delete node_modules/electron and try installing again
at getElectronPath (D:\openSources\mixin\desktop-app\node_modules\electron\index.js:14:11)
at Object.<anonymous> (D:\openSources\mixin\desktop-app\node_modules\electron\index.js:18:18)
at Module._compile (internal/modules/cjs/loader.js:945:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:962:10)
at Module.load (internal/modules/cjs/loader.js:798:32)
at Function.Module._load (internal/modules/cjs/loader.js:711:12)
at Module.require (internal/modules/cjs/loader.js:838:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (D:\openSources\mixin\desktop-app\node_modules\vue-cli-plugin-electron-builder\lib\testWithSpectron.js:2:22)
at Module._compile (internal/modules/cjs/loader.js:945:30)
error Command failed with exit code 1.
npm --registry https://registry.npm.taobao.org install electron
手动安装electron时依然报错——
> node install.js
Downloading electron-v7.1.14-win32-x64.zip: [====================================================================================================] 100% ETA: 0.0 seconds
(node:13260) UnhandledPromiseRejectionWarning: RequestError: read ECONNRESET
at ClientRequest.<anonymous> (D:\openSources\mixin\desktop-app\node_modules\got\source\request-as-event-emitter.js:178:14)
at Object.onceWrapper (events.js:300:26)
at ClientRequest.emit (events.js:215:7)
at ClientRequest.origin.emit (D:\openSources\mixin\desktop-app\node_modules\@szmarczak\http-timer\source\index.js:37:11)
at TLSSocket.socketErrorListener (_http_client.js:406:9)
at TLSSocket.emit (events.js:210:5)
at emitErrorNT (internal/streams/destroy.js:91:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:59:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
(node:13260) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:13260) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
这样就正式到github electron release下载对应的版本electron-v7.1.14-win32-x64.zip
可以完成electorn的安装。从github的官方issue里也可以看到这种情况是因为在安装过程中出现hang现象(手动强制暂停后,又重新进行安装)
The error message actually occurs when you cancel the hanging install and nevertheless try to run the project.
靠谱,没报错,但也没启动起来应用:(
Failed to fetch extension, trying 4 more times
Failed to fetch extension, trying 3 more times
Failed to fetch extension, trying 2 more times
Failed to fetch extension, trying 1 more times
Failed to fetch extension, trying 0 more times
Vue Devtools failed to install: Error: net::ERR_CONNECTION_RESET
根据yarn.lock中定义的electron@^v8.2.5
从这里进行下载(vpn需要使用直连模式,转发模式无法下载)后,解压到 node_modules\electron
目录下,并且手动增加path.txt
文件。写入绝对路径。
electron可以正常启动。项目也正常编译,但运行失败了——
- Bundling main process...
No type errors found
Version: typescript 3.7.5
Time: 6574ms
DONE Compiled successfully in 2077ms17:46:29
File Size Gzipped
dist_electron\index.js 1424.07 KiB 277.96 KiB
Images and other types of assets omitted.
INFO Launching Electron...
�ļ�����Ŀ¼������������ȷ��
(node:30396) UnhandledPromiseRejectionWarning: Error: spawn D:\openSources\mixin\desktop-app\node_modules\electron\dist\D:\openSources\mixin\desktop-app\node_modules\electron\electron.exe ENOENT
at notFoundError (D:\openSources\mixin\desktop-app\node_modules\vue-cli-plugin-electron-builder\node_modules\cross-spawn\lib\enoent.js:6:26)
at verifyENOENT (D:\openSources\mixin\desktop-app\node_modules\vue-cli-plugin-electron-builder\node_modules\cross-spawn\lib\enoent.js:40:16)
at ChildProcess.cp.emit (D:\openSources\mixin\desktop-app\node_modules\vue-cli-plugin-electron-builder\node_modules\cross-spawn\lib\enoent.js:27:25)
at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
(node:30396) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:30396) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
看起来是在对应的目录没找到electron.exe,再手动帮助它一波:新建dist目录,将下载的zip文件解压到dist目录下。
启动成功:)
App running at:
- Local: http://localhost:8080/
- Network: http://192.168.1.106:8080/
Note that the development build is not optimized.
To create a production build, run yarn build.
\ Bundling main process...
DONE Compiled successfully in 2116ms 18:16:43
File Size Gzipped
dist_electron\index.js 1424.07 KiB 277.96 KiB
Images and other types of assets omitted.
INFO Launching Electron...
(electron) The default value of app.allowRendererProcessReuse is deprecated, it is currently "false". It will change to be "true" in Electron 9. For more information please check https://github.com/electron/electron/issues/18397
comments powered by Disqus