Skip to content

验证当前NPM源地址

sh
npm config get registry
npm config get registry

国内镜像

sh
npm config set registry http://mirrors.cloud.tencent.com/npm/
npm config set registry http://mirrors.cloud.tencent.com/npm/
sh
npm config set registry https://registry.npmmirror.com
npm config set registry https://registry.npmmirror.com
sh
npm config set registry https://mirrors.huaweicloud.com/repository/npm/
npm config set registry https://mirrors.huaweicloud.com/repository/npm/

恢复默认源

sh
npm config set registry=https://registry.npmjs.org
npm config set registry=https://registry.npmjs.org

通过使用淘宝定制的cnpm安装

sh
npm install -g cnpm --registry=https://registry.npmmirror.com   # 安装cnpm
cnpm install xxx    # 使用cnpm
npm install -g cnpm --registry=https://registry.npmmirror.com   # 安装cnpm
cnpm install xxx    # 使用cnpm