vue 安装electron-builder报错


通过命令 vue add electron-builder 安装 electron-builder 报如下错误:

D:\Code\Web\StudyOrTest\vue_init> vue add electron-builder
 WARN  There are uncommitted changes in the current repository, it's recommended to commit or stash them first.
? Still proceed? Yes

�  Installing vue-cli-plugin-electron-builder...

yarn add v1.22.10
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.1.3: The platform "win32" is incompatible with this module.
info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.13: The platform "win32" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
[4/4] ⠠ electron
[-/4] ⠠ waiting...
[3/4] ⠠ yorkie
error D:\Code\Web\StudyOrTest\vue_init\node_modules\electron: Command failed.
Exit code: 1
Command: node install.js
Arguments:
Directory: D:\Code\Web\StudyOrTest\vue_init\node_modules\electron
Output:
RequestError: unable to verify the first certificate
    at ClientRequest.<anonymous> (D:\Code\Web\StudyOrTest\vue_init\node_modules\got\source\request-as-event-emitter.js:178:14)
    at Object.onceWrapper (events.js:422:26)
    at ClientRequest.emit (events.js:327:22)
    at ClientRequest.origin.emit (D:\Code\Web\StudyOrTest\vue_init\node_modules\@szmarczak\http-timer\source\index.js:37:11)
    at TLSSocket.socketErrorListener (_http_client.js:426:9)
    at TLSSocket.emit (events.js:315:20)
    at emitErrorNT (internal/streams/destroy.js:92:8)



 ERROR  command failed: yarn add vue-cli-plugin-electron-builder -D --tilde
  • 错误原因

自己在网上找了一圈,都没有找到为什么错了,看到 unable to verify the first certificate 错误提示的时候,我还以为和之前yarn安装包报错是同一个问题(问题参见 yarn安装包时报 unable to verify the first certificate 错误 ),但是自己一看设置没有问题。

之后我将问题聚焦到了错误提示的第 19 到 23 行,即如下内容:

error D:\Code\Web\StudyOrTest\vue_init\node_modules\electron: Command failed.
Exit code: 1
Command: node install.js
Arguments:
Directory: D:\Code\Web\StudyOrTest\vue_init\node_modules\electron

自己在网上搜索了一下,发现这个好像是安装 electron 的信息,所以猜测可能是安装 electron 这一步出了问题。

下一步我用 yarn add electron --dev 命令单独安装 electron ,果然报了同样的错误。但是自己之前也是通过同样的步骤去安装 electron 时并没有这个错误,中间自己做过的操作就是为了提升包的下载速度将下载源从官方源切换到了淘宝源。

自己验证了一下猜想,将安装源切换回官方源(由于我是用yarn安装的,所以需要将yarn和npm的安装源都切换回官方源), electron 立马就安装成功了。

原因: 通过淘宝源安装 electron-builder 导致的。

  • 解决方案

找到原因了,也就好解决了,通过如下命令将yarn和npm的安装源切换回官方源即可。

yarn config set registry https://registry.yarnpkg.com		// vue初始化时,选择的时npm的不需要这一步
npm config set registry https://registry.npmjs.org


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM