返回顶部

vue——使用yarn安装electron依赖时报错:RequestError: read ECONNRESET

参考: 

1. Electron安装报错 RequestError: read ECONNRESET

https://blog.csdn.net/qq_33835370/article/details/123612429?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-1-123612429-blog-122476584.235^v43^control&spm=1001.2101.3001.4242.2&utm_relevant_index=4

2. electron安装, node install.js报错RequestError: read ECONNRESET问题解决方案

https://blog.csdn.net/shuaixingrumo/article/details/121653386?utm_medium=distribute.pc_relevant.none-task-blog-2~default~baidujs_baidulandingword~default-0-121653386-blog-123612429.235^v43^control&spm=1001.2101.3001.4242.1&utm_relevant_index=3

 3. 关于 downloadArtifact 使用方法

https://www.npmjs.com/package/@electron/get

 

我的问题

vue项目,使用yarn安装electron依赖时(yarn add electron)报错:RequestError: read ECONNRESET

 

原因

依赖源问题

 

解决方法

1.进入 node_modules/electron文件下, 编辑install.js文件

2. 修改downloadArtifact这段代码, 添加淘宝镜像地址https://npm.taobao.org/mirrors/electron

原来downloadArtifact部分:

 修改后:

downloadArtifact({
  version,
  artifactName: 'electron',
  force: process.env.force_no_cache === 'true',
  cacheRoot: process.env.electron_config_cache,
  checksums: process.env.electron_use_remote_checksums ?? process.env.npm_config_electron_use_remote_checksums ? undefined : require('./checksums.json'),
   // 重点!!
   mirrorOptions: {
    mirror: 'https://npm.taobao.org/mirrors/electron',
    platform,
    arch,    
  },
}).then(extractFile).catch(err => {
  console.error(err.stack);
  process.exit(1);
});

3.执行命令:yarn add electron

 

posted @ 2024-02-29 17:36  前端-xyq  阅读(996)  评论(0编辑  收藏  举报