前言
最近胖哥开始发力electron,趁上午不是那么想做题于是跟着研究了一下,结果安装就成了个问题。
问题描述
首先使用:
yarn add electron
tyarn add electron
得到的结果一样,并没有报错,但是只要检测electron版本就会报:
❯ npx electron -v
Electron failed to install correctly, please delete node_modules/electron and try installing again
解决
首先贴出解决办法,还是只能用npm来安装:
npm i electron --save
或者设置淘宝镜像安装:
❯ npm install -g cnpm --registry=https://registry.npm.taobao.org
❯ cnpm install -g electron
然后发现可以了:
❯ npx electron -v
v8.0.0
无用尝试
- 为yarn设置淘宝镜像:
❯ yarn config set registry https://registry.npm.taobao.org
- 配置 Electron 源,添加环境变量
ELECTRON_MIRROR
http://npm.taobao.org/mirrors/electron/
- node-gyp和python等问题
这个尚不清楚,因为我都安装过,python2版本我也安装了