Nodejs installation and use, Nodejs Installation and Use

Source: Internet
Author: User

Nodejs installation and use, Nodejs Installation and Use
1. Download
:
Https://nodejs.org/download/


Installation 2
1. You can directly double-click the win7 system to run it;
2 win8 requires the Administrator permission to run the program. Otherwise, Error 2502 and Error 2503 are reported;
Specific process reference: http://jingyan.baidu.com/article/a3a3f811ee92268da2eb8af2.html


3. Execute the script
1. Open cmd and enter node-v to view the current version.
2. Open cmd and enter console. log ("Hello world! "); The Hello world!
3. Create a new main. js file with the following content:

Function main () {console. log ("Hello world! ");} Main ();

Open cmd and enter "node main. js" to execute the step main. js. You can see that the output is "Hello world!


4. Create an http server
Var http = require ("http"); http. createServer (function (req, res) {res. writehead( 200, {"Content_type": "text/html"}); res. write (" 

Run main. js and open the browser and enter: http: // 127.0.0.1: 800/. You can see:




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.