{"id":5571,"date":"2021-04-12T18:16:46","date_gmt":"2021-04-12T18:16:46","guid":{"rendered":"https:\/\/linuxways.net\/?p=5571"},"modified":"2021-04-12T18:16:46","modified_gmt":"2021-04-12T18:16:46","slug":"how-to-install-node-js-on-centos-8","status":"publish","type":"post","link":"https:\/\/linuxways.net\/de\/centos\/how-to-install-node-js-on-centos-8\/","title":{"rendered":"How to Install Node.js on CentOS 8"},"content":{"rendered":"<p>Node.js is a cross-platform, runtime environment that was built on Chrome\u2019s JavaScript. This environment is designed to execute JavaScript code on the server-side. Using the NodeJS framework, you can build many useful applications. When you install NodeJS on your CentOS or any other Linux distribution, the supportive npm packages also automatically install on your system that allows developers to share and reuse the code.<\/p>\n<p>In this article, we will discuss two different ways for the installation of NodeJS on CentOS 8 distribution through the command line. The NodeJS along with npm can install on your CentOS 8 system by using the following two methods:<\/p>\n<ul>\n<li>Install NodeJS using the CentOS 8 repository<\/li>\n<li>Install NodeJS using the NVM<\/li>\n<\/ul>\n<h2>Method 1: Install NodeJS using the CentOS 8 repository<\/h2>\n<p>The NodeJS modules can be installed directly from the official CentOS 8 repository. While we are writing this tutorial, the latest available version of NodeJS is v10.x.<\/p>\n<p>Use the following command to list the modules that contain the NodeJS packages:<\/p>\n<pre>$ sudo yum module list nodejs<\/pre>\n<p>The following output displays on the terminal that means the NodeJS package is available with multiple streams.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1114\" height=\"351\" class=\"wp-image-5572\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image.png 1114w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-300x95.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-1024x323.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-768x242.png 768w\" sizes=\"auto, (max-width: 1114px) 100vw, 1114px\" \/><\/p>\n<p>There are four different profiles of the NodeJS package.\u00a0 The one marked with [d] is a default profile, it installs a set of common runtime packages. However, use the following command to install the Nodejs package on CentOS 8 system:<\/p>\n<pre>$ sudo yum module install nodejs<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1190\" height=\"760\" class=\"wp-image-5573\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-1.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-1.png 1190w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-1-300x192.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-1-1024x654.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-1-768x490.png 768w\" sizes=\"auto, (max-width: 1190px) 100vw, 1190px\" \/><\/p>\n<p>The above-mentioned command also installs the required NPM modules after, pressing the \u2018y\u2019 and then \u2018Enter\u2019 key.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1197\" height=\"756\" class=\"wp-image-5574\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-2.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-2.png 1197w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-2-300x189.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-2-1024x647.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-2-768x485.png 768w\" sizes=\"auto, (max-width: 1197px) 100vw, 1197px\" \/><\/p>\n<p>The other Nodejs profile is the development profile, which installs some additional packages that are necessary to build the loadable modules dynamically. Use the following command to install a development profile of NodeJS:<\/p>\n<pre>$ sudo yum module install nodejs\/development<\/pre>\n<p>Once the NodeJS installation is completed, type the following command to check the installed version:<\/p>\n<pre>$ node --version<\/pre>\n<p>From the following screenshot, here, you can see that NodeJS version 10.24.0 has been installed on the CentOS 8 system.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1134\" height=\"86\" class=\"wp-image-5575\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-3.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-3.png 1134w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-3-300x23.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-3-1024x78.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-3-768x58.png 768w\" sizes=\"auto, (max-width: 1134px) 100vw, 1134px\" \/><\/p>\n<p>The above-explained method is a sufficient and easiest way for the NodeJS and npm installation on CentOS 8.<\/p>\n<h2>Install required NodeJS Development Tools<\/h2>\n<p>The development tools are required for compiling and installing the add-ons from the npm registry. So, install the all necessary development tools by running the following command:<\/p>\n<pre>$ sudo dnf groupinstall 'Development Tools'<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1192\" height=\"757\" class=\"wp-image-5576\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-4.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-4.png 1192w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-4-300x191.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-4-1024x650.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-4-768x488.png 768w\" sizes=\"auto, (max-width: 1192px) 100vw, 1192px\" \/><\/p>\n<p>Press \u2018y\u2019 and then \u2018Enter\u2019 to install all necessary development packages.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1198\" height=\"772\" class=\"wp-image-5577\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-5.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-5.png 1198w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-5-300x193.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-5-1024x660.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-5-768x495.png 768w\" sizes=\"auto, (max-width: 1198px) 100vw, 1198px\" \/><\/p>\n<h2>Remove or Uninstall the NodeJS<\/h2>\n<p>Use the following command, to remove or uninstall the NodeJS and npm modules from your CentOS 8 system:<\/p>\n<pre>$ sudo yum module remove nodejs<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1194\" height=\"730\" class=\"wp-image-5578\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-6.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-6.png 1194w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-6-300x183.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-6-1024x626.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-6-768x470.png 768w\" sizes=\"auto, (max-width: 1194px) 100vw, 1194px\" \/><\/p>\n<h2>Method 2: Install NodeJS using the NVM<\/h2>\n<p>Using the NVM (Node Version Manager) bash script, you can install and manage the NodeJS version on need. The NVM allows you to install or remove any NodeJS version from your CentOS 8 system that you want to test or use. So, use the following script to install the NVM on your CentOS 8 system:<\/p>\n<pre>$ curl -o- https:\/\/raw.githubusercontent.com\/nvm-sh\/nvm\/v0.35.3\/install.sh | bash<\/pre>\n<p>The above installation script clones the NVM repository from Github to the ~\/.nvm directory and exports the nvm path to your Bash_profile.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1099\" height=\"470\" class=\"wp-image-5579\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-7.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-7.png 1099w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-7-300x128.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-7-1024x438.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-7-768x328.png 768w\" sizes=\"auto, (max-width: 1099px) 100vw, 1099px\" \/><\/p>\n<p>To install the NodeJS using the nvm script, either, execute the commands that are printed on your terminal\u2019s window or open a new shell session. After that, use the following command to install the nodejs stable version:<\/p>\n<pre>$ nvm install node<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1096\" height=\"380\" class=\"wp-image-5580\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-8.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-8.png 1096w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-8-300x104.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-8-1024x355.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-8-768x266.png 768w\" sizes=\"auto, (max-width: 1096px) 100vw, 1096px\" \/><\/p>\n<p>In the next step, install the latest version of NodeJS using the NVM by running the below-mentioned command:<\/p>\n<pre>$ nvm install \u2013lts<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"1094\" height=\"243\" class=\"wp-image-5581\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-9.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-9.png 1094w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-9-300x67.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-9-1024x227.png 1024w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-9-768x171.png 768w\" sizes=\"auto, (max-width: 1094px) 100vw, 1094px\" \/><\/p>\n<p>Once the NodeJS is installed on your CentOS 8 system, list the all installed versions of NodeJS by executing the following command:<\/p>\n<pre>$ nvm ls<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" width=\"931\" height=\"441\" class=\"wp-image-5582\" src=\"http:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-10.png\" srcset=\"https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-10.png 931w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-10-300x142.png 300w, https:\/\/linuxways.net\/wp-content\/uploads\/2021\/04\/word-image-10-768x364.png 768w\" sizes=\"auto, (max-width: 931px) 100vw, 931px\" \/><\/p>\n<p>The default version v15.12.0 is currently using on this system, but, you can also change this version and use another NodeJS version by using the following command:<\/p>\n<pre>$ nvm use v14.16.0<\/pre>\n<p>To change the default version to another, use the following command:<\/p>\n<pre>$ nvm alias default v12.13.0<\/pre>\n<h2>Conclusion<\/h2>\n<p>We have elaborated on two different methods in this article for the installation of NodeJS on the CentOS 8 system. Now, you can choose any one of both based on your preferences. Now, NodeJS is installed on your CentOS 8 system, you can deploy a NodeJS application on the system.<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>\n<p>&nbsp;<\/p>","protected":false},"excerpt":{"rendered":"<p>Node.js is a cross-platform, runtime environment that was built on Chrome\u2019s JavaScript. This environment is designed to execute JavaScript code on the server-side. Using the NodeJS framework, you&hellip;<\/p>","protected":false},"author":1,"featured_media":5686,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[93,259],"class_list":["post-5571","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-centos","tag-centos-8","tag-node-js"],"_links":{"self":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/5571","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/comments?post=5571"}],"version-history":[{"count":0,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/posts\/5571\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media\/5686"}],"wp:attachment":[{"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/media?parent=5571"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/categories?post=5571"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/linuxways.net\/de\/wp-json\/wp\/v2\/tags?post=5571"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}