Win7 Installation configuration node.js+express development environment _node.js

Source: Internet
Author: User
Tags install node

1. Install Node.js.

Access to the official website of the download address: http://www.nodejs.org/download/. Select Windows Installer or select Windows Installer (. msi) 32-bit to download the installation package. When the download is complete, double-click install.

2. Install Express.

Installed through the NMP Package Manager, the installation is divided into: Global installation: Automatically installed under the "c:\users\[Current user]\appdata\roaming\npm", and automatically add the path to the environment variable "path". Local installation: Installed in the current directory, the path will not be added to the environment variable "PAHT". For ease of use and to run the Express command on any path in the command line, the preferred global installation. Ok! Now type "NPM Install-g Express" on the command line. Note: "-G" is the global installation option, no this is a local installation.

3. Create Express project.

4. Open Package.json, edit template engine

"Jade": ">= 0.0.1" changed to "Ejs": ">= 0.6.0"

After saving, switch to cmd execution

NPM installl

Check the current directory for Package.json and install the required extensions automatically.

The site Directory is more node_modules, this directory is the extension library files.

Express originally brought the Jade template engine personally do not like, so use the Ejs template, syntax and JSP.

Node App.js

Open the browser http://127.0.0.1:3000/can be accessed.

Now let's look at creating a project

Now there's the Express

Express commands are installed in the global only to work!

So express installation will use NPM install Express-g

or modify the global path directly:

NPM config set prefix "C:\Program Files\nodejs"

NPM config set cache "C:\Program Files\nodejs\cache" (first built cache directory)

Type: Express MyApp (MyApp is a random project name)

You'll find one more C:\Program Files\nodejs\myapp directory

By default: automatically creates

These documents, do not explain, I believe that have developed experience in the students can be a glance.

Copy Node_modules to MyApp below

The environment is built to this completion, the following do a demo test!

Create a new helloworld.js under MyApp

var http = require ("http");
Http.createserver (function (request, response) { 
  Response.writehead ({"Content-type": "Text/plain"}); 
  Response.Write ("Hello World"); 
  Response.End ();
}). Listen (8888);
Console.log ("Nodejs Start listen 8888 port!");

Enter the Node.js command prompt Commands window and enter the C:\Program Files\nodejs\myapp directory

Type node Helloworld.js

Open Address http://127.0.0.1:8888/

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.