How to install Node.js__js in CentOS

Source: Internet
Author: User
Tags install node
method One: Install Node.js from Epel library

An effective and simple way to install node.js is to download the installation from the official library, first ensuring that you have access to the Epel library, and you can install it by running the following command.

sudo yum install epel-release

You can now install node.js using the Yum command.

sudo yum install Nodejs

Because I need to manage the node bundle during the development process, I will also install the new publicly managed Package manager, using the following command.
(Note: Since the new Nodejs has already integrated NPM, this step can be ignored.) )

sudo yum install NPM

Check:

# node--version
v6.12.2
# npm--version
3.10.10

As you can see, the version is older when installed in this way. method Two: Download the source code, compile the installation

Go to the official website to find the latest or the node.js version that you want, copy the URL, and use wget to download in the CentOS.

wget https://nodejs.org/dist/v8.9.4/node-v8.9.4.tar.gz

Extract:

Tar zxvf node-v8.9.4.tar.gz

Enter directory:

CD node-v8.9.4

Configuration:

./configure

Compile:

Make

Installation:

sudo make install

Check:

# node--version
v8.9.4
# npm--version
5.6.0

Wow. The version is not new a lot. Test

Write a Hello world test.

Vim Something.js

Input:

Console.log ("Hello World");

Run:

# node Something.js 
Hello World

What the. It's too easy. Amount of ... One more.

# cat Hello.js 

var http = require (' http ');

Http.createserver (function (request, response) { 
        response.writehead ({' Content-type ': ' Text/plain '});
        Response.End (' Hello world\n ');
Listen (8080);

Console.log (' Server started ');

Execute # Node Hello.js, and then open the browser, enter: ip:8080

Haha, you have completed a web development, is not very excited about it.

Reference article: http://www.linuxidc.com/Linux/2015-02/113554.htm

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.