Home > Operation and Maintenance > Linux 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
Release: 2023-05-11 20:52:11
forward
1730 people have browsed it

1. Uninstall npm first

sudo npm uninstall npm -g
Copy after login

2. Uninstall node

yum remove nodejs npm -y
Copy after login

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
Copy after login

Unzip:

 xz -d node-v12.13.1-linux-x64.tar.xz
 tar -xvf node-v12.13.1-linux-x64.tar
Copy after login

Move to local directory:

mv node-v12.13.1-linux-x64  /usr/local/
Copy after login

Rename:

mv /usr/local/node-v12.13.1-linux-x64/  /usr/local/node
Copy after login

Add environment configuration:

vim /etc/profile
Copy after login

Add content at the end of the file:

export NODE_HOME=/usr/local/node
export PATH=$NODE_HOME/bin:$PATH
Copy after login

Execute source to make the environment variables effective immediately.

source /etc/profile
Copy after login

Check the version and complete the installation as follows.

node -v
Copy after login

can output version information, that is, ok

npm -v
Copy after login

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!

Related labels:
source:yisu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template