linux yum 安装node,CentOS7 下 yum安装新版nodejs

系统的yum源安装nodejs版本太低。

如果你的系统版本比较低,gcc库版本低,编译安装的时候有可能不成功,所以准备工作。

sudo yum install gcc-c++ make

下面是yum安装的步骤:

第一步,设置RPM源

curl -sL https://rpm.nodesource.com/setup_12.x | bash -

## Installing the NodeSource Node.js 12.x repo...

## Inspecting system...

+ rpm -q --whatprovides redhat-release || rpm -q --whatprovides centos-release || rpm -q --whatprovides cloudlinux-release || rpm -q --whatprovides sl-release

+ uname -m

## Confirming "el7-x86_64" is supported...

+ curl -sLf -o /dev/null 'https://rpm.nodesource.com/pub_12.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

## Downloading release setup RPM...

+ mktemp

+ curl -sL -o '/tmp/tmp.R9LRnQvO7i' 'https://rpm.nodesource.com/pub_12.x/el/7/x86_64/nodesource-release-el7-1.noarch.rpm'

## Installing release setup RPM...

+ rpm -i --nosignature --force '/tmp/tmp.R9LRnQvO7i'

## Cleaning up...

+ rm -f '/tmp/tmp.R9LRnQvO7i'

## Checking for existing installations...

+ rpm -qa 'node|npm' | grep -v nodesource

## Run `sudo yum install -y nodejs` to install Node.js 12.x and npm.

## You may also need development tools to build native addons:

sudo yum install gcc-c++ make

## To install the Yarn package manager, run:

curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo

sudo yum install yarn

第二步,安装Nodejs

sudo yum install -y nodejs

如果以上步骤不能安装 最新版 node,执行以下命令后再重新执行安装命令:

sudo yum clean all

清理源仓库设置

如果存在多个 nodesoucre,执行以下命令删除,从第一步重新操作

sudo rm -fv /etc/yum.repos.d/nodesource*

本文由 ez 创作,采用 知识共享署名 3.0 中国大陆许可协议 进行许可。

可自由转载、引用,但需署名作者且注明文章出处。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值