二进制安装
1. 下载解压
1 wget https://cdn.npm.taobao.org/dist/node/v12.16.2/node-v12.16.2-linux-x64.tar.xz 2 tar -xf node-v12.16.2-linux-x64.tar.xz 3 mv node-v12.16.2-linux-x64 /usr/local/node
2. 添加到环境变量
1 ln -s /usr/local/node/bin/node /usr/local/bin/node 2 ln -s /usr/local/node/bin/npm /usr/local/bin/npm 3 node -v
源码编辑安装
1. 下载解压
1 yum -y install gcc make cmake 2 wget https://cdn.npm.taobao.org/dist/node/v12.16.2/node-v12.16.2.tar.gz 3 tar -xzvf node-v12.16.2.tar.gz 4 mv node-v12.16.2 /usr/local/node 5 cd /usr/local/node
2. 编译安装
1 ./configure 2 make 3 make install
3. 添加到环境变量
1 ln -s /usr/local/node/bin/node /usr/local/bin/node 2 ln -s /usr/local/node/bin/npm /usr/local/bin/npm 3 node -v
设置镜像源
1. 查看当前源
1 npm config get registry
2. 更换npm源为国内淘宝镜像
1 npm config set registry http://registry.npm.taobao.org/
3. 或者更换为国内npm官方镜像
1 npm config set registry http://registry.cnpmjs.org/
4. 还原npm源
1 npm config set registry https://registry.npmjs.org/标签:node,npm,v12.16,centos,nodejs,local,usr,bin,安装 From: https://www.cnblogs.com/leonliuo/p/16727120.html