一、臨時使用
npm --registry https://registry.npm.taobao.org install express
二、永久使用
npm config set registry https://registry.npm.taobao.org
通過
npm config get registry 查看是否配置成功
npm config list #查看npm當前配置
或者
編輯 ~/.npmrc 加入下面內容
registry= https://registry.npm.taobao.org
三、通過cnpm使用
npm install -g cnpm --registry=https://registry.npm.taobao.org
四、設置回官網
npm config set registry https://registry.npmjs.org
五、強制清理npm的緩存
npm cache clear --force
npm config delete registry npm config delete disturl