How to install Node.js and npm on CentOS 8

npm is the abbreviation Node Package Manager, which is Node.js default package manager, can help developers to share and reuse their code. It also refers to the world's largest software repository for publishing open source software package Node.js

From the CentOS repositories to install Node.js and npm

You can install Node.js and npm from the standard CentOS repository. At this writing, Node.js version in the repository is v10.x.

By running the following command to list providing module nodejs package:

Nodejs display output module only for a Stream. Stream 10 represents the Node.js version.

CentOS-8 - AppStream                            1.8 MB/s | 6.3 MB    00:03   
CentOS-8 - Base                                2.5 MB/s | 7.9 MB    00:03   
CentOS-8 - Extras                              937  B/s | 2.1 kB    00:02   
Extra Packages for Enterprise Linux 8 - x86_64  784 kB/s | 3.5 MB    00:04   
google-chrome                                  1.5 kB/s | 3.5 kB    00:02   
Remi's Modular repository for Enterprise Linux  104 kB/s | 509 kB    00:04   
Safe Remi's RPM repository for Enterprise Linux 133 kB/s | 1.4 MB    00:10   
CentOS-8 - AppStream
Name      Stream    Profiles                                Summary           
nodejs    10 [d]    common [d], development, minimal, s2i  Javascript runtime 

Hint: [d]efault, [e]nabled, [x]disabled, [i]nstalled

How to install Node.js and npm on CentOS 8

nodejs package provides four different profiles. Default profile (labeled [d] configuration file) will be installed a generic runtime package group.

To install the default Node.js packages on CentOS system, enter:

How to install Node.js and npm on CentOS 8

The above command will install NPM.

If you're a developer, please install the developer profile, the profile will also install other libraries constructed dynamically loadable modules required.

After the installation is complete, verify by typing the following:

This command displays Node.js version:

v10.16.3

How to install Node.js and npm on CentOS 8

This is the easiest way to install Node.js and npm in CentOS 8, for the majority of use cases should be adequate.

Installation Development Tools

Development tools for the npm registry to compile and install native add-in is required. Install the package by running the following command:

How to install Node.js and npm on CentOS 8

Uninstall Node.js

If for some reason you want to uninstall Node.js and npm package, use the following command:

sudo yum module install nodejs

NVM installation using Node.js and npm

NVM (Node Manager version) is a bash script that lets you manage multiple Node.js based version of each user. Use NVM, you can install and uninstall any Node.js version to use or testing.

To install the NVM on a CentOS system, run the following command. Do not use sudo, as it will enable scripting for the root user.

Denial of connection, be resolved using the following command:

How to install Node.js and npm on CentOS 8

The installation script will add NVM from Github repository and cloned into the ~ / .nvm directory, nvm path to your Bash or ZSH configuration file.

To start using nvm script, open a command to print on a new Shell session or run the screen. Make it easier for you to do.

Now, on CentOS enabled nvm scripts, you can install the latest stable version of Node.js using the following command:

How to install Node.js and npm on CentOS 8

Let's install two versions, the latest version and 10.16.0 LTS version:

How to install Node.js and npm on CentOS 8

How to install Node.js and npm on CentOS 8

After the installation is complete, you can list all Node.js version installed by typing the following command:

Right arrowed entry (-> v13.1.0) Shell session using the current version. Version used by default when you open a new Shell session is set to v13.0.1.

If you want to change the currently active version, for example v12.13.0, you can run:

nvm use v12.13.0

How to install Node.js and npm on CentOS 8

To change the default Node.js v12.13.0, use:

nvm alias default v12.13.0

to sum up

We show you two ways to install Node.js and npm on CentOS 8. The method you choose depends on your requirements and preferences.

Now that you've installed Node.js on CentOS 8 system, it is time to deploy the application.

If you have any questions or feedback, please post a comment below.

Guess you like

Origin www.linuxidc.com/Linux/2019-11/161447.htm