中文 English

Installing the Latest Version of Node and NPM on CentOS 7

Published: 2021-01-27
centos installation node npm Aliyun mirror

Downloading Node:

mkdir ~/nodejs
cd ~/nodejs
wget https://npm.taobao.org/mirrors/node/latest-v15.x/node-v15.7.0-linux-x64.tar.gz
tar -xvzf node-v15.7.0-linux-x64.tar.gz

Renaming to node

mv node-v15.7.0-linux-x64 node

Configuring Environment Variables

vim /etc/profile
#set for nodejs  
export NODE_HOME=/root/nodejs/node  
export PATH=$NODE_HOME/bin:$PATH
source /etc/profile

If it doesn’t take effect, restart the system.

Verifying Node and NPM Installation

If the version number is displayed, the installation was successful

# node -v
v8.0.0
# npm -v
5.0.0

Note: node and npm are not yet available globally and require linking (use your actual paths)

ln -s /root/nodejs/node/bin/node /usr/local/bin/node 
ln -s /root/nodejs/node/bin/npm  /usr/local/bin/npm 

References:

Centos7:安装node和npm & npm配置全局路径 淘宝 NPM 镜像