Manual upgrade of node version under CentOs

  • 2020-12-13 19:15:34
  • OfStack

1. To find the corresponding nodejs packages, specific reference https: / / nodejs org/download/release /

2. The location of the switch to install node here as/lib / / usr local nodejs

No existence can be established

 mkdir /usr/local/lib/nodejs

3. Download


wget node-v8.12.0-linux-x64.tar.xz

4. The decompression


 tar -xJvf node-8.12.0-linux-x64.tar.xz -C /usr/local/lib/nodejs 
 mv /usr/local/lib/nodejs/node-8.12.0-linux /usr/local/lib/nodejs/node-8.12.0

5. Configure environment variables

vim ~/.profile

Enter the following


 export NODEJS_HOME=/usr/local/lib/nodejs/node-8.12.0/bin
 export PATH=$NODEJS_HOME:$PATH

6. Refresh the environment variable immediately

~/.profile

7. Test version

 node -v

8. Establish system links to simplify the call


 sudo ln -s /usr/local/lib/nodejs/node-8.12.0/bin/node /usr/bin/node
 sudo ln -s /usr/local/lib/nodejs/node-8.12.0/bin/npm /usr/bin/npm
 sudo ln -s /usr/local/lib/nodejs/node-8.12.0/bin/npx /usr/bin/npx

conclusion


Related articles: