-
通过官方查询需要安装的版本
https://github.com/nodesource/distributions -
在CentOS下获取相应版本的nodejs资源(以NodeJS 14.x为例)
粘贴 curl -sL https://rpm.nodesource.com/setup_14.x | sudo bash - -
运行 sudo yum install -y nodejs 进行nodejs安装
You may also need development tools to build native addons:
sudo yum install gcc-c++ make
To install the Yarn package manager, run:
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install yarn
- 确认安装成功
node -v
npm -v
- 安装cnpm
npm install -g cnpm -registry=https://registry.npm.taobao.org
- 修改cpm的源
npm config set registry https://registry.npm.taobao.org
- 查看源是否修改成功
npm config get registry