Original address: http://blog.csdn.net/haidaochen/article/details/7257655
The red font is what I added.
node. JS installation under Windows platform
Go directly to Nodejs's official website http://nodejs.org/Download Nodejs installation program, double-click on the installation can be
To test whether the installation was successful:
At the command line input node–v should be able to view the Nodejs version number of the current installation
A simple example
Write a short code, save it as helloworld.js, and see how Nodejs is used.
As follows: The code is primarily to create an HTTP server.
var http = require ("http"); Http.createserver (function (request, response) { Response.writehead ($, {"Content-type": "Text/html"}); Response.Write ("Hello world!"); Response.End (); }). Listen (8080);
Open the command line and go to the path where the current file is stored and run the Node helloworld.js command
If everything works, you can see the command line output: Server running at http://localhost:8080/
At the same time, in the browser input http://localhost:8080/, you can see a page written HelloWorld.
Installing NPM
NPM has a lot of good nodejs packages to solve common problems, such as using Node-mysql, you can easily link to MySQL through the Nodejs, database operation
In the development process will often need to use other packages, using NPM can download these packages for the program to call
A) If the system does not have Git installed, you can download the files required by NPM directly to HTTPS://GITHUB.COM/ISAACS/NPM.
b) If you have git, you can download it using Git.
git clone--recursive git://github.com/isaacs/npm.git
After downloading to the NPM file, the command line first goes to the NPM location and enters the following code to install it.
Node Cli.js install NPM-GF
Install Express
Express is a common framework for NODEJS. (A/b two optional One, note the difference )
A) Global installation
NPM Install EXPRESS-GD
b) installed under the current folder
NPM Install Express
After the installation is successful, the command line prompts NPM info OK
-G represents the installation to the Lib in Node_path, and the-D represents the installation of the dependency kit. If you do not have-G, the current directory will be installed (a Node_modules folder will be created).
Referencing Express packages in projects
Cases:
var express = require (' Express '); var app = Module.exports = Express.createserver ();
If you do not have Express installed, you first need to install an express in the current project folder
After the command line goes to the current path, run
NPM Install Express
Once the installation is complete, you can see a "node_modules" folder in the current directory with an "Express" folder
Note: Packages referenced in the project will be installed in the "Node_modules" folder
Create a project with Express
Enter "Express project name" on the command line to create a new project under the current folder
The following files are included:
With this method, just create an empty project framework, and a simple instance program, run App.js can view (also need to install the Jade package in the project file directory, method similar to install Express)
Reference website:
node. JS Foundation Http://www.infoq.com/cn/master-nodejs
node. js Getting Started Tutorial http://nodebeginner.org/index-zh-cn.html
node. JS Chinese Document Http://cnodejs.org/cman/index.html
Express Document Http://expressjs.com/guide.html#routing
Cnode Community http://club.cnodejs.org/
Common operations with Command line:
1) After the file is run, bring up the command input field again with CTRL + C
2) go to a disk under F:
3) go to a folder under CD F:\nodeExamples
4) go back to the parent directory CD.
Finally, attach the download file to the installation directory table:
Nodejs installation files
Npm,express installation directory
Nodejs Project Deployment Drop location
Nodejs Building a deployment environment tutorial under the Windows platform