Construction of NODE,JS development environment

Source: Internet
Author: User

1.node.js development environment Download, but according to their own use of the computer and the operating system used in the actual situation, specifically as follows:
https://nodejs.org/en/download/
2. Test after installation
(1) Use the following command to view the current Node version:
$ node-v
v4.4.3
(2) You can also perform npm-v to verify that the NPM tool is successfully installed with node.
$ npm-v
3.10.10
3. Interactive mode
Open terminal, type node into the command interaction mode, you can enter a code statement immediately after execution and display the results, for example:
$ node
> Console.log (' Hello world! ');
Hello world!
4. Script mode
Here's our first node. JS Program:
(1) Edit the content of Hello.js with Notepad, save it in d:\\, the content is as follows:
Const HTTP = require (' http ');

const hostname = ' 127.0.0.1 ';
Const PORT = 3000;

Const SERVER = Http.createserver ((req, res) = = {
Res.statuscode = 200;
Res.setheader (' Content-type ', ' text/plain ');
Res.end (' Hello world\n ');
});

Server.listen (port, hostname, () = {
Console.log (' Server running at http://${hostname}:${port}/');
});
(2) Open the CMD console, enter node D:\\hello.js, and the console displays the following statement:
Server running at Http://127.0.0.1:3000/
(3) Open the computer or browser and enter Http://127.0.0.1:3000/
It will appear: Hello world.

Construction of NODE,JS development environment

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.