Node undefined不是server.js文件中的函数

时间:2015-02-28 23:44:07

标签: javascript node.js

app.configure有问题:

debugger;

var appSettings = require('./server/config/settings/MainAppSettings.js');

// ====== DB ==============
//var sqlImport = require('./server/dbConnectors/MYSQL/MYSQLMainConn.js');
//var dbConnection = new sqlImport.sqlConn();
var dbConnection = null;

// ====== setup basic server ==============
var root = __dirname; 
var express = require('express');
var app = express();

app.configure(function () {
    app.use(express.json());
    app.use(express.urlencoded());
    app.use(express.methodOverride());
    app.use(app.router);
    app.use(express.errorHandler({dumbExceptions:true, showStack:true}));
});

// ====== SSL ==============
var https = require('https');
var fs = require('fs');

// This line is from the Node.js HTTPS documentation.
var options = {
    key: fs.readFileSync(appSettings.key1.key),
    cert: fs.readFileSync(appSettings.key1.cert)
};

// ====== Routes ==============
//handle get requests
var errors = require('./server/errors/errors.js').errors;
require('./server/config/routes/routes.js')(app, dbConnection, errors);

//keep server from crashing by catching all exceptions not caught before
process.on('uncaughtException', function(err) {
    console.log(err);
});

//launch http server
app.listen(appSettings.ports.http);
console.log('Express http server listening on port %d in %s mode',appSettings.ports.http, app.settings.env);

//launch https server
https.createServer(options, app).listen(appSettings.ports.https, function(){
    console.log('Express https server listening on port %d in %s mode',appSettings.ports.https, app.settings.env);
});

module.exports = app;

1 个答案:

答案 0 :(得分:1)

好像您正在使用已移除configure的Express 4.0。 见http://expressjs.com/guide/migrating-4.html#other-changes