NPM更换国内源

NPM简介

NPM是随同NodeJS一起安装的包管理工具,能解决NodeJS代码部署上的很多问题,常见的使用场景有以下几种:

  • 允许用户从NPM服务器下载别人编写的第三方包到本地使用。
  • 允许用户从NPM服务器下载并安装别人编写的命令行程序到本地使用。
  • 允许用户将自己编写的包或命令行程序上传到NPM服务器供别人使用。

换源

显示当前的镜像网址:

1
npm get registry

显示:https://registry.npmjs.org/

更换淘宝的镜像网址:

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

再次查看当前镜像:

1
npm get registry

显示:http://registry.npm.taobao.org/

更换成功!

 

遇到报错

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
*npm ERR! code ENOTFOUND*``
 
*npm ERR! errno ENOTFOUND*
 
*npm ERR! network request to http://registry.npm.taobao.org/hexo-helper-live2d failed, reason: getaddrinfo ENOTFOUND registry.npm.taobao.org*
 
*npm ERR! network This is a problem related to network connectivity.*
 
*npm ERR! network In most cases you are behind a proxy or have bad network settings.*
 
*npm ERR! network*
 
*npm ERR! network If you are behind a proxy, please make sure that the*
 
*npm ERR! network 'proxy' config is set properly. See: 'npm help config'*
 
*npm ERR! A complete log of this run can be found in:*
 
*npm ERR! /Users/joseph_wilson/.npm/_logs/2020-03-21T09_51_58_938Z-debug.log*

使用下面代码解决:

1
npm --registry http://registry.cnpmjs.org info underscore

 

posted @   _成飞  阅读(6778)  评论(0编辑  收藏  举报
编辑推荐:
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
阅读排行:
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)
点击右上角即可分享
微信分享提示