码迷,mamicode.com
首页 > 移动开发 > 详细

node app.js不起作用的解决方法

时间:2014-05-22 12:14:27      阅读:349      评论:0      收藏:0      [点我收藏+]

标签:nodejs

In Express 3.0, you normally would use app.configure() (or app.use() ) to set up the required middleware you need. Those middleware you specified are bundled together with Express 3.0.

e.g.

var express = require(‘express‘);
var routes = require(‘./routes‘);
var user = require(‘./routes/user‘);
var http = require(‘http‘);
var path = require(‘path‘);

var app = express();

// all environments
app.set(‘port‘, process.env.PORT || 3000);
app.set(‘views‘, path.join(__dirname, ‘views‘));
app.set(‘view engine‘, ‘jade‘);
app.use(express.favicon());
app.use(express.logger(‘dev‘));
app.use(express.compress());
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());

In Express 4.0 however, all middleware have been removed so that they can be maintained and update independently from the core Express (except the static middleware), thus they need to be called separately (what you see in app.js).

The bin\ directory serve as a location where you can define your various startup scripts, the www is an example on how it should looks like, ultimately you could have startup script like teststop or restart etc. Having this structure allows you to have different configurations without touching the app.js.

所以这正确启动的方式是 npm start

node app.js不起作用的解决方法,布布扣,bubuko.com

node app.js不起作用的解决方法

标签:nodejs

原文地址:http://blog.csdn.net/edagarli/article/details/26287763

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!