1、CentOS7
# 准备编译环境
yum -y install gcc gcc-c++ openssl-devel
# 切换目录
cd /usr/local
# 下载Node12.16.2压缩包
wget http://nodejs.org/dist/v12.16.2/node-v12.16.2-linux-x64.tar.gz
# 解压
tar -zxvf node-v12.16.2-linux-x64.tar.gz
# 重命名文件夹
mv node-v12.16.2-linux-x64 node
# 编辑文件
vim ~/.bashrc
# 添加
export PATH=$PATH:/usr/local/node/bin
# 更新生效
source ~/.bashrc
# 验证环境
node -v
# 设置npm源
npm config set registry https://registry.npmmirror.com
# 验证源
npm config get registry
# npm替换为cnpm
npm install -g cnpm --registry=https://registry.npmmirror.com
文章评论