electron安装失败时配置

electron下载前配置

使用命令打开npm全局配置,C盘下的.npmrc文件。

npm config edit

然后在空白处添加

electron_builder_binaries_mirror=https://npmmirror.com/mirrors/electron-builder-binaries/
electron_mirror=https://cdn.npmmirror.com/binaries/electron/
registry=https://registry.npmmirror.com/

或者直接在项目里新建.npmrc文件,优先级最高。同样添加以上路径。

如果使用yarn install下载依赖失败,可以试试npm update

yarn install

npm update

npm 及 yarn 代理设置及更换为国内下载源

npm安装完成默认不走代理,所在如果公司内网是通过代理访问外部网站,npm则会出现安装插件失败情况

设置代理

npm config set proxy http://127.0.0.1:8080
npm config set https-proxy http://127.0.0.1:8080

yarn config set proxy http://127.0.0.1:8080
yarn config set https-proxy http://127.0.0.1:8080

删除代理

npm config delete proxy
npm config delete https-proxy

yarn config delete proxy
yarn config delete https-proxy

国外源速度不稳定,可设置国内淘宝源。

查看现有源

npm config get registry

yarn config get registry

npm和yarn转换淘宝源和官方源

npm config set registry http://registry.npm.taobao.org/
npm config set registry https://registry.npmjs.org/

yarn config set registry http://registry.npm.taobao.org/
yarn config set registry https://registry.npmjs.org/

你可能感兴趣的:(electron,javascript,前端)