Node installation

1. Download

Node official website download address

2. Install

First, we’ll move to the /usr/src directory, which is typically used to store software sources

cd /usr
Copy the code

Download the node

Wget HTTP: / / https://nodejs.org/dist/v12.18.3/node-v12.18.3-linux-x64.tar.xzCopy the code

Unpack the

# tar. Xz suffix: unzip.xz, then unzip.tarXz -d node-v12.18.3-linux-x64.tar.xz tar - XVF node-v12.18.3-linux-x64.tar#. Tar. Gz suffixThe tar - XZVF node - v12.18.3 - Linux - x64. Tar. GzCopy the code

Change the directory name (node-v12.18.3-linux-x64 to: nodejs; Of course, you don’t have to.)

Node - mv v12.18.3 - Linux - x64 nodejsCopy the code

Viewing the Installation Path

cd nodejs
pwd
# /usr/nodejs
Copy the code

Go to the nodejs directory and configure the environment variables in.basrch

cd nodejs
vim .basrch
## Add environment variables to.basrch
# export NODE_HOME=/usr/nodejs
# export PATH=$PATH:$NODE_HOME/bin 
# export NODE_PATH=$NODE_HOME/lib/node_modules
Copy the code

Save basrch.

:wq
Copy the code

submit

source .basrch
Copy the code

Check whether the installation is successful

node -v
# v12.18.3
npm -v
# 6.14.6
Copy the code