改动npm包管理器的registry为淘宝镜像(npm.taobao.org)

起因

安装了node。安装了npm之后,官方的源实在是 太慢了!

看了看淘宝的npm镜像, http://npm.taobao.org/ 
居然说让我再下载一个cnpm,要不然就每次都得install的时候,后面加上--registry 。。
你是在逗我么?
你能够直接看 结论
改registry仅适用于你仅仅下载。不往npm上publish的场景。

授之以渔

信息太少,npm -l 之 。

看到了这个config命令。

 
npm help config
 
没有什么可用信息。果断看 see also 结果发现npm-config(7)里面有和registry相关的东西。(为什么是registry?由于淘宝上写了,每次都让你--registry啊)
 
好了,基本确定registry是我们须要改的地方。怎么改? npm help config
发现了例如以下好东西:
先来npm config list一下试试 
 
配置项都在这里。

结论和重点

那么 npm config set registry "https://registry.npm.taobao.org"
再次list一下
已经在了。
好了 如今你能够试一试你的npm install是不是快一些了。

 



原文地址:https://www.cnblogs.com/llguanli/p/7069991.html