51工具盒子

依楼听风雨
笑看云卷云舒,淡观潮起潮落

nodejs之npm切换源

npm 源地址 {#npm-%E6%BA%90%E5%9C%B0%E5%9D%80}

1. 查看当前地址 {#1.-%E6%9F%A5%E7%9C%8B%E5%BD%93%E5%89%8D%E5%9C%B0%E5%9D%80}

npm config get registry
npm config get disturl

2. 设置当前地址(设置为淘宝镜像) {#2.-%E8%AE%BE%E7%BD%AE%E5%BD%93%E5%89%8D%E5%9C%B0%E5%9D%80%EF%BC%88%E8%AE%BE%E7%BD%AE%E4%B8%BA%E6%B7%98%E5%AE%9D%E9%95%9C%E5%83%8F%EF%BC%89}

npm config set registry http://registry.npm.taobao.org/

3. 设置当前地址(设置为默认地址) {#3.-%E8%AE%BE%E7%BD%AE%E5%BD%93%E5%89%8D%E5%9C%B0%E5%9D%80%EF%BC%88%E8%AE%BE%E7%BD%AE%E4%B8%BA%E9%BB%98%E8%AE%A4%E5%9C%B0%E5%9D%80%EF%BC%89}

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

4. 每次执行命令前加入--registry指定仓库路径 {#4.-%E6%AF%8F%E6%AC%A1%E6%89%A7%E8%A1%8C%E5%91%BD%E4%BB%A4%E5%89%8D%E5%8A%A0%E5%85%A5%E2%80%93registry%E6%8C%87%E5%AE%9A%E4%BB%93%E5%BA%93%E8%B7%AF%E5%BE%84}

npm --registry https://registry.npm.taobao.org install

5. 使用nrm工具切换淘宝源 {#5.-%E4%BD%BF%E7%94%A8nrm%E5%B7%A5%E5%85%B7%E5%88%87%E6%8D%A2%E6%B7%98%E5%AE%9D%E6%BA%90}

npx nrm use taobao

6.如果之后需要切换回官方源可使用 {#6.%E5%A6%82%E6%9E%9C%E4%B9%8B%E5%90%8E%E9%9C%80%E8%A6%81%E5%88%87%E6%8D%A2%E5%9B%9E%E5%AE%98%E6%96%B9%E6%BA%90%E5%8F%AF%E4%BD%BF%E7%94%A8}

npx nrm use npm
赞(0)
未经允许不得转载:工具盒子 » nodejs之npm切换源