Simple nodejs installation and environment configuration in windows

Source: Internet
Author: User

I believe that nodejs is no longer a strange word for many people who are concerned about javascript development. Related information about nodejs has been overwhelming on the Internet. Because of its high concurrency, it has created its special application position.

At present, the highest concern in China, the best maintenance of a node. js site should be http://www.cnodejs.org/

I don't want to talk about too much node. js information here. Let's just talk about the simple node. js environment configuration in windows.

Step 1: Download the Installation File

: Official http://www.nodejs.org/download/

Here we use

Step 2: Install nodejs

After the download is complete, double-click the node-v0.8.16-x86.msi, start to install nodejs, the default is installed in C: \ Program Files \ nodejs below

Step 3: Install related environments

Open the C: \ Program Files \ nodejs directory and you will find that npm is included in it. You can directly use npm to install the environment

Enter the node. js command prompt command window

Go to the nodejs installation directory C: \ Program Files \ nodejs

Run the following command: cd C: \ Program Files \ nodejs:

Now start to install the relevant environment

Enter the command: npm express and press enter to wait for the installation of express ........

Enter the command: npm jade and press enter to wait for jade installation ........

Enter the command: npm mysql and press enter to wait for mysql installation ........

What components are installed depends on the environment construction requirements

By default, the above components are installed in the C: \ Program Files \ nodejs \ node_modules folder, which is also the automatic search path for node. js-related components.

Step 4: Create a project

Now there is express

Type: express myapp (myapp is a random project name)

You will find an additional C: \ Program Files \ nodejs \ myapp directory

By default

I don't want to explain these files. I believe that anyone with development experience can understand them at a glance.

Copy node_modules to myapp

After the environment is set up, we will perform a demo test!

Create helloworld. js under myapp

Copy codeThe Code is as follows: var http = require ("http ");
Http. createServer (function (request, response ){
Response. writeHead (200, {"Content-Type": "text/plain "});
Response. write ("Hello World ");
Response. end ();
}). Listen (8888 );
Console. log ("nodejs start listen 8888 port! ");

Go to the node. js command prompt command window and enter the C: \ Program Files \ nodejs \ myapp directory.

Type node helloworld. js

Http: // 127.0.0.1: 8888/

Output: Hello World

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.