Electronjs builds cross-platform desktop applications using JavaScript, HTML and CSS based on NodeJS. www.electronjs.org/

start

From github.com/electron/el… Download the basic configuration, decompress it locally, and run NPM I to install the dependencies.

There are large dependency files in the electronjs plug-in, so it will take too long to install electronjs directly by using NPM I. You can install the.nPMRc configuration file under the root directory of the project by using Taobao image. The content is as follows:

registry=https://registry.npm.taobao.org/
disturl=https://npm.taobao.org/mirrors/node
ELECTRON_MIRROR="https://npm.taobao.org/mirrors/electron/"
ELECTRON_CUSTOM_DIR="9.0.5"
Copy the code

After saving the file, install NPM I again. The installation will be successful very quickly.

Start development mode

After the installation is successful, you can run the NPM start command to start the system. After the installation is successful, a window will automatically pop up with the following information:

Hello World! We are using node. js 12.14.1, Chromium 83.0.4103.119, and Electron 9.0.5.Copy the code

The ElectronJS installation and startup are now normal.

Package production document

The electronjs package exe production file requires the installation of additional dependencies,

npm install electron-packager -g --registry=https://registry.npm.taobao.org
Copy the code

Also add a command to script in package.json:

"build": "Electron packager. myClient --win --out./myClient --arch=x64 --app-version=0.0.1 --electron version=9.0.5"
Copy the code

It means:

  • MyClient Application name
  • — WIN: Packaging platform (Take Windows as an example)
  • –out .. /myClient: output directory
  • – the arch = 64:64
  • –app-version=0.0.1: indicates the application version
  • –electron version electronjs version number (latest version 9.0.5)

Then run NPM run build, the myClient directory will generate a packaged folder, you can find the myClient.exe file, that is, a normal desktop application.

The original address: www.playsn.com/electronjs make…