Nodejs v8.9.4 Installation

Source: Internet
Author: User

one. Installation
Environment Centos7.3 64-bit

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

CD node-v8.9.4/

./configure--prefix=/usr/local/nodejs
Make
Make install

Two. Nodejs Setting environment variables
vim/etc/profile.d/nodejs.sh
#输入以下内容
Export Nodejs_home=/usr/local/nodejs
Path= $PATH: $NODEJS _home/bin

Refresh Environment Variables
source/etc/profile.d/nodejs.sh

Three. Testing
Run the project Web.js
var http = require (' http ');
Http.createserver (function (req, res) {
Res.writehead ($, {' Content-type ': ' Text/plain '});
Res.end (' Hello world\n ');
}). Listen (1337, ' 127.0.0.1 ');
Console.log (' Server running at http://127.0.0.1:1337/');
To run the server, put the code in a file Example.js and execute it with the node program from the command line:

% Node Example.js
Server running at http://127.0.0.1:1337/
Here are an example of a simple TCP server which listens on port 1337 and echoes whatever you send it:

var net = require (' net ');

var server = Net.createserver (socket) {
Socket.write (' Echo server\r\n ');
Socket.pipe (socket);
});

Server.listen (1337, ' 127.0.0.1 ');

Nodejs v8.9.4 Installation

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.