Yum is the default package manager for centos. You can install the software in one click with the yum -y install softwareName command.

Due to the rapid development of the front-end, the Nodejs version installed through Yum is relatively old (the latest stable version is v14.x). For this, I used to download the source code directly to install it, although it is convenient, but today I found that you can install the specified version of Node through yum.

How to specify the Node version installed for yum

Type the command curl — silent – the location https://rpm.nodesource.com/setup_${number}. X | bash

Such as long-term stability of the latest version of the LTS (14) : curl, silent – the location https://rpm.nodesource.com/setup_14.x | bash

Access the address corresponding to the content of the curl said, and https://rpm.nodesource.com/setup_14.x is a shell steps:

#! /bin/bash
SCRSUFFIX="_14.x"
NODENAME="Node.js 14.x"
NODEREPO="pub_14.x"
NODEPKG="nodejs"

print_status() {
  local outp=$(echo "$1") # | sed -r 's/\n/\n## /mg')
  echo
  echo -e "## ${outp}"
  echo
}
## omit
Copy the code

And | is pipeline operator, said by bash execute the shell content, steps of yum node did some modification and setting up the source address

Start the installation

After the configuration, run the yum install -y nodejs command. After the installation is complete, enter Node -v to view the software version.

The last

In this article, you can install the specified version of Node using yum on centos.

Engineers need to know how to use the power of tools to save valuable time.