npm或pnpm安装electron失败解决办法
1.
pnpm:
pnpm config set electron_mirror "https://npm.taobao.org/mirrors/electron/"
npm:
npm config set electron_mirror "https://npm.taobao.org/mirrors/electron/"
2.
pnpm install electron
npm install electron
另一种解决办法:
npm install electron 后,进入postinstall安装后,ctrl终止进程
进入Releases · electron/electron (github.com) 页面下载对应平台zip包:
如window下载electron-v15.3.0-win32-x64.zip
下载完成后,把zip文件放进node_modules/electron目录中
修改node_modules/electron中的install.js文件
注释如下代码:
downloadArtifact({ version, artifactName: 'electron', force: process.env.force_no_cache === 'true', cacheRoot: process.env.electron_config_cache, checksums: process.env.electron_use_remote_checksums ? undefined : require('./checksums.json'), platform, arch }).then(extractFile).catch(err => { console.error(err.stack); process.exit(1); });
在注释代码的下方添加如下代码:
extractFile('./electron-v15.3.0-win32-x64.zip')
然后终端进入node_modules/electron,运行命令node install.js
之后会在electron文件夹中生成一个dist目录,就完成了