How to Install Node.js and npm on CentOS 7
npm, short for Node Package Manager is the default bundle chief for Node.js and the world's biggest programming archive for the distributing of open-source Node.js bundles.
This instructional exercise strolls you through the means to introduce Node.js and npm on a CentOS 7 machine. We will show both of you various methods of introducing Node.js and npm.
In the initial segment of this instructional exercise we will introduce Node.js and npm utilizing the yum bundle director from the NodeSource store. In the subsequent part, we will show you how to introduce Node.js and npm utilizing the nvm content.
In the event that you need Node.js just for sending Node.js applications, at that point the most straightforward alternative is to introduce the Node.js bundles utilizing yum from the NodeSource vault.
Prior to proceeding with this instructional exercise, ensure you are signed in as a client with sudo advantages .
Installing Node.js and npm on CentOS 7
NodeSource is an organization devoted to giving undertaking grade Node backing and they keep a reliably refreshed Node.js storehouse for Linux disseminations.
To introduce Node.js and npm from the NodeSource vaults on your CentOS 7 framework, follow these means:
1. Add NodeSource yum repository
The current LTS variant of Node.js is form 10.x. On the off chance that you need to introduce rendition 8 simply change setup_10.x with setup_8.x in the order beneath.
Run the accompanying twist order to add the NodeSource yum storehouse to your framework:
curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
2. Install Node.js and npm
When the NodeSource storehouse is empowered, introduce Node.js and npm by composing:
sudo yum install nodejs
When provoked to import the store GPG key, type y, and press Enter.
3. Verify the Node.js and npm Installation
To watch that the establishment was effective, run the accompanying orders which will print the Node.js and npm renditions.
Print npm version:
How to install Node.js and npm using NVM
NVM (Node Version Manager) is a slam content used to deal with different dynamic Node.js renditions. NVM permits us to introduce and uninstall a particular Node.js adaptation which implies we can have quite a few Node.js variants we need to utilize or test.
To introduce Node.js and npm utilizing NVM on your CentOS framework, follow these means:
1. Install NVM (Node Version Manager)
To download the nvm introduce content run the accompanying order:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
The content will clone the nvm store from Github to ~/.nvm and add the content Path to your Bash or ZSH profile.
=> Close and reopen your terminal to start using nvm or run the following to use it now: export NVM_DIR="$HOME/.nvm" [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
As the yield above shows, you should either close and return your terminal or run the orders to add the way to nvm content to your present meeting.
To confirm that nvm was appropriately introduced type:
2. Install Node.js using NVM
Presently that the nvm device is introduced we can introduce the most recent accessible adaptation of Node.js, by composing:
nvm install node
Downloading and installing node v11.0.0... Downloading https://nodejs.org/dist/v11.0.0/node-v11.0.0-linux-x64.tar.xz... ######################################################################## 100.0% Computing checksum with sha256sum Checksums matched! Now using node v11.0.0 (npm v6.4.1) Creating default alias: default -> node (-> v11.0.0)
Check the Node.js form, by composing:
3. Install multiple Node.js versions using NVM
We should introduce two additional variants, the most recent LTS form and form 8.12.0
nvm install --lts nvm install 8.12.0
When LTS form and 8.12.0 are introduced to list all introduced Node.js cases type:
-> v8.12.0 # ACTIVE VERSION v10.13.0 v11.0.0 default -> node (-> v11.0.0) # DEFAULT VERSION node -> stable (-> v11.0.0) (default) stable -> 11.0 (-> v11.0.0) (default) iojs -> N/A (default) lts/* -> lts/dubnium (-> v10.13.0) lts/argon -> v4.9.1 (-> N/A) lts/boron -> v6.14.4 (-> N/A) lts/carbon -> v8.12.0 lts/dubnium -> v10.13.0
The yield reveal to us that the section with a bolt on the left (- > v8.12.0), is the adaptation utilized in the current shell meeting and the default variant is set to v11.0.0. Default variant is the form that will be dynamic when opening new shells.
To change the presently dynamic adaptation you can utilize the accompanying order:
nvm use 10.13.0
The yield will look like something this:
Now using node v10.13.0 (npm v6.4.1)
To change the default Node.js variant sort:
nvm alias default 10.13.0
default -> 10.13.0 (-> v10.13.0)
Install development tools
To have the option to fabricate local modules from npm we should introduce the advancement apparatuses and libraries:
sudo yum install gcc-c++ make
We have indicated both of you various approaches to introduce Node.js and npm on your CentOS 7 worker. The technique you pick relies upon your necessities and inclinations. While introducing the bundled adaptation from the NodeSource store is simpler, the nvm technique gives you greater adaptability for adding and eliminating diverse Node.js forms on a for every client premise.
You can likewise check this instructional exercise about How to introduce and utilize yarn on CentOS 7 .
On the off chance that you have any inquiries or input, don't hesitate to remark underneath.
FFmpeg is a free and open-source assortment of devices for taking care of sight and sound documents. It contains a lot of shared sound and video li...
FFmpeg is a free and open-source order line apparatus for transcoding sight and sound records. It contains a bunch of shared sound and video librar...
A cron work is an errand that is executed at indicated spans. The errands can be planned to run by a moment, hour, day of the month, month, day of ...
Python is one of the most generally utilized programming dialects on the planet. With its basic and simple to learn punctuation, Python is a mainst...
TeamViewer is a cross-stage arrangement that can be utilized for controller, work area sharing and record move between PCs. TeamViewer is exclusive...
This article discloses how to set up a static IP address on Ubuntu 20.04. Regularly, in most organization designs, the IP address is alloted...
sudo is an order line utility that permits confided in clients to run orders as another client, of course root. This instructional exercise ...
On CentOS, the framework's timezone is set during the introduce, however it tends to be handily changed sometime in the not too distant future....
Java is one of the most well known programming dialects on the planet, utilized for building various kinds of cross-stage applications. This...
Python is one of the most well known programming dialects on the planet. With its straightforward and simple to learn grammar, Python is a famous d...
The mouseenter event permits us to set off a way of behaving when the client mouses over a component. Study this and other mouse events. Precise i...
Normally the hostname is set during the establishment of the working framework or progressively appointed to the virtual machine when it is made.&n...
Nagios is a mainstream open-source checking programming. It keeps a stock of your whole IT foundation and guarantees your organizations, workers, a...
In CodeIgniter, there is a zip library for creating a zip file but there is no library available for extracting the zip file. To extrac...
Records are one of the most ordinarily utilized information types in Python and are utilized to store assortments of things of a similar sort. ...
Apache is an open-source and cross-stage HTTP worker. It comes stacked with amazing highlights and can be additionally stretched out with a wide as...
Introduction React empowers engineers to compose reusable code as parts. This particular methodology simplifies it to create hearty applications b...
Boa constrictor is the most mainstream Python/R information science and AI stage. It is utilized for huge scope information preparing, prescient in...
In this instructional exercise, we will tell you the best way to make a bootable Ubuntu USB stick from the Linux terminal. You can utilize this USB...