许多人卡在Downloading electron-v9.1.0-darwin-x64.zip
这里,在网上不少答案都说去electron mirror去下载zip放在缓存目录,固然,在较早的electron版本是ok的,可是node
因为
@electron/get
包的修改,使上文中方法无效
解决方法:
使用命令安装:git
ELECTRON_MIRROR="https://cdn.npm.taobao.org/dist/electron/" npm install electron
参考连接:github
相信不少人在npm install的时候,会遇到报错:Error: EACCES: permission denied, mkdtemp '/usr/local/lib/node_modules/electron/electron-download-Jbbf4p'
即便使用了sudo依然无效。
解决方法:
npm install 添加参数 --unsafe-permnpm
sudo ELECTRON_MIRROR="https://cdn.npm.taobao.org/dist/electron/" npm install electron -g --unsafe-perm
这是全局安装,若是安装在项目里就把-g改为-D便可。
参考资料:
https://docs.npmjs.com/misc/config#unsafe-perm--unsafe-perm缓存
unsafe-perm
Default: false if running as root, true otherwise
Type: Boolean
Set to true to suppress the UID/GID switching when running package scripts.If set explicitly to false, then installing as a non-root user will fail.安全
解决了这两个问题,相信安装electron应该没有什么困难了。electron