【Electron】Project construction and packaging error failure stepping pit problem collection

1. About electron-xxxx.zip installation and download failure

It is usually caused by the network and needs to be downloaded over the wall.
The solution is to use it (Taobao source or official source is acceptable) and set the electron warehouse as the source of Taobao

# 官方源
npm config set registry https://registry.npmjs.org
yarn config set registry https://registry.yarnpkg.com
# 淘宝源
npm config set registry  https://registry.npm.taobao.org
yarn config set registry  https://registry.npm.taobao.org
# 设置electron仓库为淘宝的源 主要是这一步起作用 上面可以使用官方源
# 注意https://npm.taobao.org/mirrors/electron/最后的斜杠不要省略
# 注意url最后的斜杠不要省略
# 注意url最后的斜杠不要省略
npm config set electron_mirror https://npm.taobao.org/mirrors/electron/
yarn config set electron_mirror https://npm.taobao.org/mirrors/electron/

**If it still doesn't work, you can configure the corresponding address and version in "build" => "electronDownload" in the package.json file configuration. (You can also write a packaging configuration file electron-builder.json separately)
**

 "electronDownload": {
    
    
    "mirror": "https://npm.taobao.org/mirrors/electron/",
    "customDir": "v12.0.4"
  },

2.出现错误Application entry file “dist\electron\main.js” in the “…\build\win-unpacked\resources\app.asar” does not exist

**This is because "build" => "files" in the package.json file configuration does not configure the corresponding files that need to be packaged. (You can also write a packaging configuration file electron-builder.json separately)
**


"files": [
    "**/*",
    "resources",
    "preview",
    "!app",
    "!dcm",
    "!main.js",
    "build",
    "package.json"
  ],

Guess you like

Origin blog.csdn.net/weixin_39085822/article/details/130405335