Nodejs download to a different disk environment configuration + build of the first HTTP server

Source: Internet
Author: User

In short, node. JS is the JavaScript that runs on the server. node. JS is a JAVASCRIPT runtime environment based on the Chrome V8 engine. node. JS uses an event-driven, non-blocking I/O model to make it lightweight and efficient. NPM is its package manager.

First, the official website download Nodejs, the path assumption is placed in the D disk.

Second, open cmd Direct input node-v and npm-v Verify the version number, confirm the installation is successful

Third, NPM config ls to view the current directory settings. You're going to find out, huh? Although the words can not understand, but there are a few of the C drive? No! how can this be?

This is the system default and does not trust the open environment variable setting. User Variable path (see, user variable) the second line. Glance. Now let's change it to D-disk.

Follow the diagram to go. Which one to change, which is not the same, change it. My installation path is: D:\nodejs

In CMD.

npm config set prefix "D:\nodejs\node_global"

npm config set cache "D:\nodejs\node_cache"

came to the system variable!

Add this to the path of the system environment variable:

Here we go, and try the NPM config ls in cmd to change it.

Four

npm install express -g //-g是全局安装的意思

NPM Install BOOSTRAP-G//temporarily useless to have a lot of bags

Five, small HTTP server

Just find a place to build a JS file.

var http=require (' http '); Http.createserver (function (request,response) {  response.writehead (200,{') Content-type ': ' Text/plain '})  Response.End ("hello,world\n");  }). Listen (2017);   

We'll explain the meaning of 200 and other numbers later.

Then cmd to you build this file path, node JS name, JS

No surprises will show.

Server runing at http://127.0.0.1:2017
Then open the browser input http://127.0.0.1:2017
And then, Hello Ward! ~
Six

URL parsing:
CMD input node
Enter URL
Input url.parse (' URL ')
If you want to go back to use format.
200:ok
400: Syntax error
401: No authorization
403: Permissions
404: Not Found
500: Unexpected error
503: currently unable to process

Seven
Download an Apache
Apache supports static pages, and Tomcat supports dynamic. Test Site performance after download: CMD to the Apache directory bin

And then type: AB-N1000-C10 http://baidu.com/

-------------------------------------------------------------------------------------------so late,-------------------------. ---------------------------------------Good Night---------------------------------------------------------------

Eat a lot of hardship, the installation of the network is very miscellaneous, there is no solution to the problem. Uninstalled the reload once, now with a very comfortable. Just learned a day, feel oneself Meng Meng da.

The web also has the theoretical content of HTTP, especially good (almost asleep).

Learn the little reptiles tomorrow. It's tempting to be ignorant of things.

Good night.


Nodejs download to a different disk environment configuration + build of the first HTTP server

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.