Electron serial port project packaging Windows installation package

Electron serial port project packaging Windows installation package

About electron-rebuild

When the Electron serial port project is established, electron-rebuild will be used for module rebuild, and the electron-build used for packaging will reject electron-rebuild. Therefore, after using electron-rebuild when initializing the serial port project, it can be uninstalled.

Install electron-builder

You can install electron-builder in the following ways:

  1. npm install –g yarn
  2. npm install electron-builder --save-dev

And check the following configuration in package.json

"postinstall": "electron-builder install-app-deps",
"build": {
    
    
    "appId": "com.xxx.app",
    "mac": {
    
    
      "target": ["dmg","zip"]
    },
    "win": {
    
    
      "target": ["nsis","zip"]
    }
},
"scripts": {
    
    
    "dist": "electron-builder --win --x64"
},

Then you can use the npm run dist command in the project directory to package the windows installation package, and the packaged file is in the dist directory under the project directory.

If you want to operate packaging through yarn, the process is as follows:

  1. npm install –g yarn

  2. Run the yarn run dist command when yarn add electron-builder --save-dev is packaged.

Precautions

  1. Sometimes the packaging process will destroy the library files in node_modules. After the packaging is completed, the installation package/green version and the original project files will fail. Therefore, before packaging the window installation package, manually set the node_modules directory to the "read-only" attribute before packaging.
    Insert picture description here
    Insert picture description here
    After the packaging is completed, the read-only control attribute of node_modules becomes invalid. Therefore, the read-only attribute of the node_modules directory needs to be reset the next time the packaging is done. In short, set the read-only attribute of node_modules every time before packaging.

  2. Note that the firewall may hinder the packaging process. If the packaging is unsuccessful, you can turn off the firewall and anti-virus software and try again.

-End-

Guess you like

Origin blog.csdn.net/hwytree/article/details/103334330