Home  >  Article  >  Operation and Maintenance  >  How to quickly uninstall and install the node environment in linux

How to quickly uninstall and install the node environment in linux

PHPz
PHPzforward
2023-05-11 20:52:111679browse

1. Uninstall npm first

sudo npm uninstall npm -g

2. Uninstall node

yum remove nodejs npm -y

See if there are any residues

Enter /usr/local/lib Delete all node and node_modules folders

Enter /usr/local/include Delete all node and node_modules folders

Enter /usr/local/bin Delete the node executable file

3. Install node

Download:

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

Unzip:

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

Move to 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 variables effective immediately.

source /etc/profile

Check the version and complete the installation as follows.

node -v

can output version information, that is, ok

npm -v

can output version information, that is, ok

The above is the detailed content of How to quickly uninstall and install the node environment in linux. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:yisu.com. If there is any infringement, please contact admin@php.cn delete