linux Server Quick Uninstall Install node Environment of Easy to Get Started

  • 2021-10-27 06:29:14
  • OfStack

1. Uninstall npm first


sudo npm uninstall npm -g

2. Uninstall node


yum remove nodejs npm -y

See if there is any residue

Enter /usr/local/lib to delete all node and node_modules folders

Enter /usr/local/include to delete all node and node_modules folders

Enter/usr/local/bin to delete the executable file of node

3. Install node

Download:


 wget https://cdn.npm.taobao.org/dist/node/v12.13.1/node-v12.13.1-linux-x64.tar.xz

Decompression:


 xz -d node-v12.13.1-linux-x64.tar.xz
 tar -xvf node-v12.13.1-linux-x64.tar

Move to the local directory:


mv node-v12.13.1-linux-x64  /usr/local/

Rename:


mv /usr/local/node-v12.13.1-linux-x64/  /usr/local/node

Add environment configuration:


vim /etc/profile

Add content at the end of the file:


export NODE_HOME=/usr/local/node
export PATH=$NODE_HOME/bin:$PATH

Execute source to make the environment variable valid immediately.


source /etc/profile

Check the version and complete the installation as follows.


node -v

Can output version information, that is, ok


yum remove nodejs npm -y
0

Can output version information, that is, ok


Related articles: