ubuntu、centos 下利用 curl 安装 nodejs

在 linux 下,用这个方案,可以方便的安装各种版本的 nodejs
更新于: 2023-07-16 10:41:05

ubuntu 安装命令如下

## install
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs

## check:
node -v
npm -v

centos 安装命令如下

## install
curl -sL https://rpm.nodesource.com/setup_16.x | sudo bash -
sudo yum install -y nodejs
# 安装 yarn
curl -sL https://dl.yarnpkg.com/rpm/yarn.repo | sudo tee /etc/yum.repos.d/yarn.repo
sudo yum install yarn

安装中的错误

重要信息: openssl11-libs-1:1.1.1k-2.el7.x86_64 conflicts with file from package openssl-libs-1:1.1.1g-15.1.al8.x86_64

关键词:openssl11-libs-1:1.1.1k-2.el7.x86_64 conflicts  openssl-libs-1:1.1.1g-15.1.al8.x86_64

Running transaction check
Transaction check succeeded.
Running transaction test
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'yum clean packages'.
Error: Transaction test error:
  file /usr/lib64/.libcrypto.so.1.1.hmac from install of openssl11-libs-1:1.1.1k-2.el7.x86_64 conflicts with file from package openssl-libs-1:1.1.1g-15.1.al8.x86_64
  file /usr/lib64/.libssl.so.1.1.hmac from install of openssl11-libs-1:1.1.1k-2.el7.x86_64 conflicts with file from package openssl-libs-1:1.1.1g-15.1.al8.x86_64
  file /usr/lib64/engines-1.1/afalg.so from install of openssl11-libs-1:1.1.1k-2.el7.x86_64 conflicts with file from package openssl-libs-1:1.1.1g-15.1.al8.x86_64
  file /usr/lib64/engines-1.1/capi.so from install of openssl11-libs-1:1.1.1k-2.el7.x86_64 conflicts with file from package openssl-libs-1:1.1.1g-15.1.al8.x86_64
  file /usr/lib64/engines-1.1/padlock.so from install of openssl11-libs-1:1.1.1k-2.el7.x86_64 conflicts with file from package openssl-libs-1:1.1.1g-15.1.al8.x86_64
  file /usr/lib64/libcrypto.so.1.1 from install of openssl11-libs-1:1.1.1k-2.el7.x86_64 conflicts with file from package openssl-libs-1:1.1.1g-15.1.al8.x86_64
  file /usr/lib64/libssl.so.1.1 from install of openssl11-libs-1:1.1.1k-2.el7.x86_64 conflicts with file from package openssl-libs-1:1.1.1g-15.1.al8.x86_64

参考