Open JQChan opened 4 years ago
https://github.com/nodejs/node/blob/master/BUILDING.md
下载Node源码
wget https://nodejs.org/dist/v12.16.3/node-v12.16.3.tar.gz
解压包,并进入解压的文件夹
tar xvf node-v12.16.3.tar.gz
cd node-v12.16.3
3. 安装`python gcc-c++ gcc make`等库 - gcc and g++ >= 6.3 or newer, or - GNU Make 3.81 or newer - Python 2.7 ```bash sudo yum install python gcc-c++ gcc make // Ubuntu sudo apt-get install build-essential sudo apt-get install gcc sudo apt-get install g++
devtoolset-8
# 1. Install a package with repository for your system: # On CentOS, install package centos-release-scl available in CentOS repository: $ sudo yum install centos-release-scl
$ sudo yum-config-manager --enable rhel-server-rhscl-7-rpms
$ sudo yum install devtoolset-8
$ scl enable devtoolset-8 bash
5. 编译 ```bash $ ./configure $ make -j4
安装
$ make install
检查是否安装成功
node -v
npm -v
8. 如果运行`node -v` 报错 ```bash -bash: /usr/bin/node: No such file or directory
node
whereis node
// 输出 node: /usr/local/bin/node
10. 增加软链接:`node`和`npm`到`/usr/bin` ```bash sudo ln -s /usr/local/bin/node /usr/bin/node sudo ln -s /usr/local/bin/npm /usr/bin/npm
npm
https://github.com/nodejs/node/blob/master/BUILDING.md
下载Node源码
解压包,并进入解压的文件夹
cd node-v12.16.3
devtoolset-8
,会升级gcc https://www.softwarecollections.org/en/scls/rhscl/devtoolset-8/On RHEL, enable RHSCL repository for you system:
$ sudo yum-config-manager --enable rhel-server-rhscl-7-rpms
2. Install the collection:
$ sudo yum install devtoolset-8
3. Start using software collections:
$ scl enable devtoolset-8 bash
安装
检查是否安装成功
npm -v
node
安装位置// 输出 node: /usr/local/bin/node
node
和npm
版本npm -v