美文网首页
npm install electron 8.5.5报错解决方案

npm install electron 8.5.5报错解决方案

作者: 该帐号已被查封_才怪 | 来源:发表于2023-07-26 14:09 被阅读0次

    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

    image.png
    新M1芯片操作系统芯片匹配不到,所以我换成Windows虚拟机了,当然这里https://www.jianshu.com/p/b1b3577fd373https://github.com/electron/electron-api-demos/issues/485 对m1芯片有解决方案,我没有尝试。
    2、还碰到过使用命令行的问题: https://www.yixuju.cn/other/talking-about-proxy/

    相关文章

      网友评论

          本文标题:npm install electron 8.5.5报错解决方案

          本文链接:https://www.haomeiwen.com/subject/meekpdtx.html