各个版本NodeJs环境配置
1.Centos7 + Node v12 nodejs12需gcc++6.3.0以上
# 如需安装gcc, 步骤如下centos升级g++7.3.0
sudo yum install centos-release-scl
sudo yum install devtoolset-7
scl enable devtoolset-7 bash
# 查看一下版本,可以看到版本已经是 7.3系列了
$ gcc --version
gcc (GCC) 7.3.1 20180303 (Red Hat 7.3.1-5)
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# 为了避免每次手动生效,可以在.bashrc中设置:
$ source /opt/rh/devtoolset-7/enable
# or
$ source scl_source enable devtoolset-7
Node安装
# yum方式安装参考 https://github.com/nodesource/distributions
# 步骤1, root权限下运行
curl -sL https://rpm.nodesource.com/setup_12.x | bash -
# 步骤2, sudo yum install -y nodejs
sudo yum install -y nodejs
yum方式如果不能安装,建议手动编译
# 选择自己合适的源下https://npm.taobao.org/mirrors/node/各种版本
# 我这里下载了源码包https://npm.taobao.org/mirrors/node/v12.6.0/node-v12.6.0.tar.gz