解决方案:
修改项目目录下的 node_modules\electron\install.js
downloadArtifact({
version,
artifactName: ‘electron‘,
force: process.env.force_no_cache === ‘true‘,
cacheRoot: process.env.electron_config_cache,
platform: process.env.npm_config_platform || process.platform,
arch: process.env.npm_config_arch || process.arch, //结尾别忘了加逗号!
//添加如下代码,
mirrorOptions:{
mirror: ‘https://npm.taobao.org/mirrors/electron/‘,
customDir: version
}
}).then((zipPath) => extractFile(zipPath)).catch((err) => onerror(err))
ps : customDir
在downloadArtifact
拼接下载地址的时候,它会自动在版本号前加上字符v
从而来下载github的镜像
github
https://github.com/electron/electron/releases/download/v7.0.0/electron-v7.0.0-win32-x64.zip
可这样,就会导致淘宝镜像下载出错!
淘宝的镜像中目录中版本目录,是不带v
的
https://npm.taobao.org/mirrors/electron/7.0.0
/electron-v7.0.0
-win32-x64.zip
再次用终端打开 项目目录下的 node_modules\electron
运行 node install.js
PS H:\codes\testElectron\node_modules\electron> node install.js
https://npm.taobao.org/mirrors/electron/7.0.0/electron-v7.0.0-win32-x64.zip
PS H:\codes\testElectron\node_modules\electron>
解决!!!
原文地址:https://www.cnblogs.com/cfsxgogogo/p/12629550.html
时间: 2024-10-08 23:09:16