nodejs
[TOC]

配置国内镜像

教程
1
npm config set registry "http://registry.npm.taobao.org/"
2
npm config set ELECTRON_MIRROR "https://npm.taobao.org/mirrors/electron/"
Copied!
换回官方镜像:
1
npm config set registry "https://registry.npmjs.org/"
2
3
# 检查是否配置成功
4
npm config get ELECTRON_MIRROR
5
npm config get registry
Copied!
npm config delete ELECTRON_MIRROR

代理

配置代理
1
npm config set proxy http://127.0.0.1:7890
2
npm config set https-proxy=https://127.0.0.1:7890
Copied!
取消代理
1
npm config delete proxy
2
npm config delete https-proxy
Copied!

npm install

npm install 默认将 package.json 的配置的环境依赖下载到当前目录下的 node_modules 中,如果想要复用这些环境依赖,可以直接加参数:-g --global
npm install -g

npm pack

1
npm run pack
2
# 或者
3
npm run dist
Copied!

electron 项目打包

npm run dist 打包失败 - 网络问题
网络问题,不能把 GitHub 上面的资源拉下来,需要手动切换淘宝镜像:
1
npm config set electron_mirror=https://npm.taobao.org/mirrors/electron/
2
npm config set electron-builder-binaries_mirror=https://npm.taobao.org/mirrors/electron-builder-binaries/
Copied!
npm run dist 打包失败 - cannot move downloaded into final location (another process downloaded faster?)
关闭火绒!!!
Last modified 12d ago