淘宝镜像配置,cnpm

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_34664239/article/details/86579926

通过 cnpm 改变镜像源地址的方式解决 npm 被墙问题,你可以使用定制的 cnpm (gzip 压缩支持) 命令行工具代替默认的 npm:

三种使用方式

1.通过cnpm使用
$ npm install -g cnpm --registry=https://registry.npm.taobao.org

//使用
cnpm install [第三方包名]
2.暂时性直接使用

只需要在下载包的时候,加上 --registry=https://registry.npm.taobao.org,
那这样的话就会通过淘宝的 cnpm 去下载

npm --registry https://registry.npm.taobao.org install [第三方包名]
3.持久使用,配置下载方式
  • 配置一下,每次默认加上 --registry=https://registry.npm.taobao.org
  • 该命令表示设置 npm 下载的镜像源地址为: https://registry.npm.taobao.org
    只要做了执行了该命令,那以后所有的 install 都会使用该地址。
// 安装镜像
$ npm config set registry=https://registry.npm.taobao.org
$ npm config set disturl https://npm.taobao.org/dist
  • 如果想要删除该配置,使用下面的命令:
// 删除镜像
$ npm config delete registry
$ npm config delete disturl  
  • 还可以通过下面的命令查看当前 npm 的配置列表:
// 查看当前配置
npm config list 

猜你喜欢

转载自blog.csdn.net/qq_34664239/article/details/86579926