node.js installation method:
first step:
64 installation package URL: https://nodejs.org/dist/v4.4.3/node-v4.4.3-x64.msi
Step two:
Enter into the command prompt box:
node -v (detection node version)
ctrl cc (exit the current node execution environment)
third step:
Taobao mirror installation, enter the command prompt box enter the command:
asl install -g cnpm --registry = https: //registry.npm.taobao.org
Comment:
npm: using a foreign resource server,
cnpm: use of domestic resources server, referred to Taobao mirror.
Soundtrack build server:
The first step: the introduction of modules:
var http= require(" http")
Step two: declare a variable with a callback function
var server = createServer(function(req,res){}.listen(3000,function(em){
if (! err) {console.log ( "service start")}}))
express framework to build server:
The first step: the introduction of express Framework
var express = require ( 'express' );
second step: introducing path module (processing path module)
var path = the require ( 'path');
Step 3: Create the server obj corresponds http.createServer
var obj = express ();
fourth step: port 3000, the callback function
obj.listen (3000, function () {
console.log ( "service start")
})
step five: set a static file resource position
obj.use (express.static (path.join (__ dirname, 'public ')));