How To Install Nodejs in CentOS7
Installed version: 8.7.0
1. Download Nodejs from the source code
cd /usr/local/src
wget https://npm.taobao.org/mirrors/node/v8.7.0/node-v8.7.0.tar.gz
2. Unzip the nodejs installation package
tar xvf node-v8.7.0.tar.gz
3. Enter the decompressed node folder and install the necessary compilation packages
cd node-v8.7.0
sudo yum install gcc gcc-c++
Here, first check the version of gcc
gcc -v
If the version number is lower than 4.9.4, please upgrade gcc first, because the gcc version requires 4.9.4+ when compiling nodejs8.7.0.
1. Get the gcc installation package and unzip it
cd /usr/local/src wget https://ftp.gnu.org/gnu/gcc/gcc-5.4.0/gcc-5.4.0.tar.bz2 tar -jxvf gcc-5.4.0.tar.bz2
Note: bz2 is a compressed file format. If it cannot be decompressed, install bzip2: yum -y install bzip2
2. Compile and install gcc-5.4.0
cd gcc-5.4.0 ./contrib/download_prerequisits mkdir build cd build ../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib make (it is recommended not to use make -j to compile, although the compilation time can be shortened, it is very likely to fail to compile) make install
If the gcc version number is 4.9.4+, or after completing the gcc upgrade, start compiling nodejs
./configure
make
Note: The make process is time-consuming and may take more than 30 minutes
Fourth, install Nodejs
sudo make install
5. Verify that it is installed correctly
node -v
Installed version: 8.7.0
1. Download Nodejs from the source code
cd /usr/local/src
wget https://npm.taobao.org/mirrors/node/v8.7.0/node-v8.7.0.tar.gz
2. Unzip the nodejs installation package
tar xvf node-v8.7.0.tar.gz
3. Enter the decompressed node folder and install the necessary compilation packages
cd node-v8.7.0
sudo yum install gcc gcc-c++
Here, first check the version of gcc
gcc -v
If the version number is lower than 4.9.4, please upgrade gcc first, because the gcc version requires 4.9.4+ when compiling nodejs8.7.0.
1. Get the gcc installation package and unzip it
cd /usr/local/src wget https://ftp.gnu.org/gnu/gcc/gcc-5.4.0/gcc-5.4.0.tar.bz2 tar -jxvf gcc-5.4.0.tar.bz2
Note: bz2 is a compressed file format. If it cannot be decompressed, install bzip2: yum -y install bzip2
2. Compile and install gcc-5.4.0
cd gcc-5.4.0 ./contrib/download_prerequisits mkdir build cd build ../configure --enable-checking=release --enable-languages=c,c++ --disable-multilib make (it is recommended not to use make -j to compile, although the compilation time can be shortened, it is very likely to fail to compile) make install
If the gcc version number is 4.9.4+, or after completing the gcc upgrade, start compiling nodejs
./configure
make
注:make过程较为耗时,可能需要30分钟以上
四、安装Nodejs
sudo make install
五、验证是否正确安装
node -v