记录一下初次使用 Electron 时遇到的问题和个人的解决办法

问题

npm installnpm start 执行完后报错

Electron failed to install correctly, please delete node_modules/electron and try installing again

解决

首先删除 node_modules 文件夹,然后执行下列命令。

# 安装 yarn
npm install yarn -g
# yarn 设置为 npmmirror 镜像
yarn config set registry https://registry.npmmirror.com
# 设置 Electron npmmirror 镜像
set "ELECTRON_MIRROR=https://npmmirror.com/mirrors/electron/" && yarn install