node. JS Development Environment Preparation

Source: Internet
Author: User

1. Install the Nodejs Windows package.

Official website: http://nodejs.org/

2, you can use CMD to run the Nodejs project, the command format:

Node filename. js

Node file name

3, for unfamiliar novice coder, can use Webstorm tool, provide the function of code hint.

Official website: http://www.jetbrains.com/webstorm/

Registration code:


Webstorm Registration Code

User Name:

Embrace

License Key:

===== LICENSE BEGIN =====

24718-12042010

00001h6wzklpfo3gmjj8xotpw5mqvy

ya8vwka9th!vibauks4fidikufy!! F

3 C "Rqcirbshpsldcft1xmji5h0yqs6

===== LICENSE END =====

4. Examples of Nodejs:

?
1 2 3 4 5 6 var http = require(‘http‘);  http.createServer(function (req, res) {    res.writeHead(200, {‘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/‘);

5. Code Logic:

A. Global method require () is used to import modules, generally directly assigns the return value of the Require () method to a variable, which can be used directly in JavaScript code. Require ("http") is the HTTP module that loads the system presets

B. Http.createserver is the method of the module, which is to create and return a new Web server object and bind a callback to the service to process the request.

C. The Http.listen () method allows the HTTP server to listen on a specific port.

D. Console.log will not have to say more, understand firebug should know, node implementation of this method.

6. Operation Effect:

7. NPM is the management tool for node. JS's module package, with the specific installation command:

NPM Install < package name >

8,node core thought: 1. Non-blocking; 2. Single thread; 3. Event-driven .

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.