download
You can download the latest version of node.js locally , and then upload it to the server through the ftp tool, or use the wget command to download directly on the server terminal (I downloaded the node-v6.11.3-linux-x64 version at the time, please check the above link for other versions Then replace it):
$ wget https://npm.taobao.org/mirrors/node/v6.11.3/node-v6.11.3-linux-x64.tar.gz
decompress
Enter the server terminal, find the uploaded or downloaded installation package, and unzip it
$ tar -zvxf node-v6.11.3-linux-x64.tar.gz
Move to the installation directory and rename
$ mv node-v6. 11.3 -linux-x64 / opt / node
Configure environment variables
Open the profile file in the etc directory
$ vi /etc/profile
Add the following at the end of the file
export NODE_HOME=/opt/node
export PATH=$NODE_HOME/bin:$PATH
Effective environment variable
$ source /etc/profile
You can also add the above environment variables to the .bash_profile file in the user's root directory
$ vi ~ / .bash_profile export NODE_HOME=/opt/node export PATH=$NODE_HOME/bin:$PATH
Check version
$ node --v v6. 11.3 $ npm - v 3.10 . 10