npm 安装时 electron 8.5.5 时遇到 Electron failed to install correctly, please delete node_modules/electron and try installing again,定位到错误源码:
image.png也就是没有找到path.txt,查看项目确实没有这个文件,搜索Electron failed to install correctly, please delete node_modules/electron and try installing again 错误 找到这篇文章https://blog.csdn.net/che_attitude/article/details/123636709 ,说 node_modules\electron目录下文件无dist文件夹,说明安装electron失败了,按照里面提示在node_modules\electron \install.js 里的
// downloads if not cached
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://npmmirror.com/mirrors/electron/',
}
}).then((zipPath) => extractFile(zipPath)).catch((err) => onerror(err))
加上这句
mirrorOptions:{
mirror:'https://npmmirror.com/mirrors/electron/',
}
image.png
并在node_modules\electron目录 执行node install.js解决了该问题;
1、另外我在mac pro m1 笔记本上 npm i vue-cli-plugin-electron-builder@1.4.6时 遇到
Failed to find Electron v5.0.0 for darwin-arm64 at https://github.com/electron/electron/releases/download/v5.0.0/chromedriver-v5.0.0-darwin-arm64.zip
新M1芯片操作系统芯片匹配不到,所以我换成Windows虚拟机了,当然这里https://www.jianshu.com/p/b1b3577fd373 和 https://github.com/electron/electron-api-demos/issues/485 对m1芯片有解决方案,我没有尝试。
2、还碰到过使用命令行的问题: https://www.yixuju.cn/other/talking-about-proxy/
网友评论