npm 安装及换源
安装 node
- 更新源
bash
curl --silent --location https://rpm.nodesource.com/setup_10.x | sudo bash -- 安装 node
bash
sudo yum -y install nodejs注意
如果以上步骤不能安装 最新版 node,执行以下命令后再执行第二步:
bashsudo yum clean all如果存在多个 nodesoucre,执行以下命令删除,然后重新执行第一第二步:
bashsudo rm -fv /etc/yum.repos.d/nodesource*
换源
通过 config 命令
bash
npm config set registry https://registry.npmmirror.com验证
bash
npm info underscore(如果上面配置正确这个命令会有字符串 response)
命令行指定
bash
npm --registry https://registry.npmmirror.com info underscore编辑 ~/.npmrc加入下面内容
bash
registry = https://registry.npmmirror.com使用 nrm 管理 registry 地址
下载 nrm
bashnpm install -g nrm添加 registry 地址
bashnrm add npm http://registry.npmjs.org nrm add npmmirror https://registry.npmmirror.com切换 npm registry 地址
bashnrm use npmmirror nrm use npm
