2

1. Install electron

I made a mistake in the first step and couldn't install it
The specific manifestation is that npm install does not report an error, but it prompts that electron is missing when it is running, and asks if it is installed.
Or you will get an error when you install it directly

Essentially, when the electron package is installed, the network is restricted and not installed

Solution 1: Use nrm to manage npm sources and then nrm use taobao to switch Taobao sources or nrm use npmMirror to try
Solution 2: Manual node ./node_modules/electron/install.js is usually stuck here
If there are the following phenomena, the installation is basically successful
5951630394365_.pic_hd.jpg

2.electron-forge

The packaging tool used in the official example, but note that it can only play the package of the system. For example, if my mac computer needs to play the windows package, it won’t work.

3.electron-packager

Install this plug-in to open windows package

// package.json 打包命令
"scripts": {
    "package-win":"electron-packager ./ --platform=win32 --out ./dist  --overwrite  --ignore=node_modules --arch=x64"
  }

But when packaging, it will say that mac lacks a win environment and needs to be installed with brew, and gave a command brew install --cask wine-stable
Look at the official documentation, it is true
image.png

4.homebrew

There is a problem with my homebrew, brew update keeps getting stuck and cannot connect to the homebrew address of github
After a day of tossing, I tried the online method and the final summary is as follows ( my situation may not apply to you, it can only be used as a reference)

  • 1 Turn off the local VPN and turn off the proxy and everything
git config --global --unset http.proxy 
git config --global --unset https.proxy
  • 2 brew config Observe that all sources use github sources, don’t use mirrors
  • 3 githubIP added to vim /etc/hosts , ping github can get ip
    image.png
    image.png
  • 4 Connect to a 5g mobile hotspot ( don’t ask me the reason. After a day of tossing, that’s how it was solved. In terms of internet speed, the download speed of 5~10M is also really good)
    Update again, it is successful, check the version, it is indeed the latest version (yes, the latest version of branch from github was issued in 19)
    image.png
    Install Win again, there is no problem, all kinds of automatic installation, and then succeed
    image.png
    image.png

5. Packaging windows software, permission issues

sudo npm run package-win  

Some dependencies will be automatically installed in the follow-up, you need to install manually, with a strong windows style
image.png

Then encountered a permission problem
image.png
The owner of this file is $USER (fyy), not root, we can't execute it with root, change its ownership and then execute it and it will be Ok.
image.png

sudo chown -R root .wine/

image.png

6. Happy packing

Then execute the packaging command to pack happily
image.png
success:
image.png


Runningfyy
1.3k 声望661 粉丝