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/