Nodejs安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
groupadd nodejs
useradd -g nodejs -m nodejs

yum install gcc-c++ zip unzip bison -y

wget https://nodejs.org/dist/v18.17.1.tar.xz # https://nodejs.org/dist/v21.0.0/node-v21.0.0-linux-x64.tar.gz
tar -xvf node-v18.17.1-linux-x64.tar.xz

mv node-v18.17.1-linux-x64 /usr/local/nodejs



vim ~/.bash_profile
export PATH=/usr/local/nodejs/bin/node:$PATH
export PATH=/usr/local/nodejs/bin/npm:$PATH
export PATH=/usr/local/nodejs/bin/npx:$PATH
source ~/.bash_profile

ln -s /usr/local/nodejs/bin/node /usr/bin/node
ln -s /usr/local/nodejs/bin/npm /usr/bin/npm
ln -s /usr/local/nodejs/bin/npx /usr/bin/npx



npm create vue@latest # 如果报错看下面的两个帖子
# https://www.cnblogs.com/dingshaohua/p/17103654.html
# https://www.cnblogs.com/xiaoko/p/16932555.html

报错解决

  1. xxx

    1
    2
    3
    4
    5
    6
    wget https://files-cdn.cnblogs.com/files/xiaoko/libstdc.so.6.0.29.zip
    unzip libstdc.so.6.0.29.zip
    mv /usr/lib64/libstdc++.so.6 libstdc++.so.6.bck
    mv libstdc.so.6.0.29 /usr/lib64/
    cd /usr/lib64
    ln -s libstdc++.so.6.0.29 libstdc++.so.6
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    # 升级GCC(默认为4 升级为8)
    yum install -y centos-release-scl
    yum install -y devtoolset-8-gcc*
    mv /usr/bin/gcc /usr/bin/gcc-4.8.5
    ln -s /opt/rh/devtoolset-8/root/bin/gcc /usr/bin/gcc
    mv /usr/bin/g++ /usr/bin/g++-4.8.5
    ln -s /opt/rh/devtoolset-8/root/bin/g++ /usr/bin/g++

    # 升级 make(默认为3 升级为4)
    wget http://ftp.gnu.org/gnu/make/make-4.3.tar.gz
    tar -xzvf make-4.3.tar.gz && cd make-4.3/
    ./configure --prefix=/usr/local/make
    make -j8 && make install
    cd /usr/bin/ && mv make make.bak
    ln -sv /usr/local/make/bin/make /usr/bin/make

    # 安装glibc
    wget http://ftp.gnu.org/gnu/glibc/glibc-2.28.tar.gz
    tar xf glibc-2.28.tar.gz
    cd glibc-2.28/ && mkdir build && cd build

    ../configure --prefix=/usr --disable-profile --enable-add-ons --with-headers=/usr/include --with-binutils=/usr/bin
    make -j8 && make install

    # 可能有lnss_test2的报错,别担心,并不影响

    npm create vue@latest
    cd vue-project
    npm install
    npm run dev
    1. /lib64/libc.so.6: version `GLIBC_2.18′ not found (required by /lib64/libstdc++.so.6

      1
      2
      3
      4
      5
      6
      7
      curl -O http://ftp.gnu.org/gnu/glibc/glibc-2.18.tar.gz
      tar zxf glibc-2.18.tar.gz
      cd glibc-2.18/
      mkdir build
      cd build/
      ../configure --prefix=/usr
      make -j2 && make install