原作者:
国内配置Electron开发环境的正确方式
- https://blog.yasking.org/a/zh-install-electron-development-2020.html
https://blog.yasking.org/a/zh-install-electron-development.html
Nodejs 15
curl -sL https://deb.nodesource.com/setup_15.x > setup15.bash
chmod 755 setup15.bash
sudo ./setup15.bash
步骤1:Windows安装nodejs和yarn
下载32位的node-v14.15.0
https://nodejs.org/dist/v14.15.0/node-v14.15.0-x86.msi
# Win10可以使用npm安装yarn
npm install -g yarn
Ubuntu 步骤0:Ubuntu 安装 nodejs 10.x 上游开发版本
curl -sL https://deb.nodesource.com/setup_10.x > setup.sh
cat setup.sh | sudo -E bash -
Ubuntu 步骤1:Ubuntu安装yarn
curl -sL https://dl.yarnpkg.com/debian/pubkey.gpg > yarnpkg-pubkey.gpg
cat yarnpkg-pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
sudo apt-get update && \
sudo apt-get install yarn gcc g++ make
步骤2:配置淘宝源
yarn config set registry https://registry.npm.taobao.org
yarn config get registry
https://registry.npm.taobao.org
Ubuntu 16.04.6 LTS
root@VirtualBox:~/src/electron-hello-world$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 16.04.6 LTS
Release: 16.04
Codename: xenial
root@VirtualBox:~/src/electron-hello-world$ python --version
Python 2.7.12
root@VirtualBox:~/src/electron-hello-world$ python3 --version
Python 3.5.2
root@VirtualBox:~/src/electron-hello-world$ node -v
v15.1.0
root@VirtualBox:~/src/electron-hello-world$ yarn -v
1.22.5
配置 Electron 源
启动应用时,需要下载已经构建好的 Electron dist 包,默认会从 Github 上下载,所以国内下载会很慢或根本无法下载,感谢淘宝提供了镜像源,设置后从国内服务器下载,速度很快。
Ubuntu 临时设置环境变量
# export ELECTRON_MIRROR=https://cdn.npm.taobao.org/dist/electron/
__ Windows Powershell 临时设置环境变量 __
$Env:ELECTRON_MIRROR="https://cdn.npm.taobao.org/dist/electron/"
electron
yarn global add electron@10.1.5
# 全局安装 node-gyp
yarn global add node-gyp
# 全局安装 node-gyp
npm install -g node-gyp
# 下载本机 Node.js 版本对应的头文件。
node-gyp install --dist-url https://npm.taobao.org/mirrors/node
网友评论