"Node. js" Mac installs Node text

Source: Internet
Author: User

1 Enter the official website, download node's latest version

Official website: https://nodejs.org/en/

2 Double-click the downloaded installation package, all the way to the default installation.

3 Open terminal, enter the following command to view the results, if the message appears, the installation is successful

4 Create a new JS file: Nodetest.js, enter the following code and save

var http = require ("http"); Http.createserver (function(request, response) {    Response.writehead ($, {        "Content-type": "Text/plain"    });    Response.Write ("Welcome to Nodejs");    Response.End ();}). Listen (8000, "127.0.0.1"); Console.log ("creat server on Http://127.0.0.1:8000/");

5 Open terminal, enter Nodetest.js directory, enter

Node NodeTest

Open Browser, type: 127.0.0.1/8000

If unable to open, you can change the. Listen (8000, "127.0.0.1") to the IP listener to. Listen (8000), and then tap or enter localhost:8000

"Node. js" Mac installs Node text

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.