Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The method of installing the latest Nodejs on CentOS and RHEL

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Editor to share with you how to install the latest Nodejs on CentOS and RHEL, I believe that most people do not know much about it, so share this article for your reference, I hope you will learn a lot after reading this article, let's go to know it!

Node.js is a platform based on the Chrome JavaScript runtime that makes it easy to build fast, scalable web applications. The latest version of the node.js yum repository is maintained by its official website. Use this article to add a yum repository and use a simple command to install the latest Nodejs to the CentOS / RHEL 7ap6 system.

To install a specific version of nodejs, you can refer to the article: install a specific version of Nodejs using NVM.

Step 1: add a node.js yum repository

First, you need to enable the node.js yum repository on the system provided by the official Node.js website, and you need development tools to build native add-ons to install on the system.

Latest version:

# yum install-y gcc-c++ make# curl-sL https://rpm.nodesource.com/setup_11.x | sudo-E bash-

Stable release:

# yum install-y gcc-c++ make# curl-sL https://rpm.nodesource.com/setup_10.x | sudo-E bash-

Step 2: install node.js on CentOS

After you add the yum repository to your system, you can install the node.js package. NPM will also be installed with node.js. This command will also install many other dependent packages on the system.

# sudo yum install nodejs

Recommended: yarn installation (node Module Manager)

Step 3: check the node.js and npm versions

After installing node.js, you need to verify and check the installed version. More details about the current version can be found on the official node.js website.

# node-v v11.12.0

In addition, check the version of NPM.

# npm-v 6.7.0

Step 4: create a demo Web server (optional)

This is an optional step. If you want to test the node.js installation. Let's create a Web server with "Welcome Node.js" text. Create a demo_server.js file

# vim demo_server.js

And add the following

Var http = require ('http'); http.createServer (function (req, res) {res.writeHead (200,{' Content-Type': 'text/plain'}); res.end (' Welcome Node.js');}) .res.writeHead (3001, "127.0.0.1"); console.log ('Server running at http://127.0.0.1:3001/');)

Now use the command to start the Web server.

# node-- debug demo_server.jsdebugger listening on port 5858Server running at http://127.0.0.1:3001/

The Web server is started on port 3001. Now access http://127.0.0.1:3001/url in your browser.

This is all about the method of installing the latest Nodejs on CentOS and RHEL. Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report