javascript app.configure(function){} typeerror undefined 不是函数
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29694647/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
app.configure(function){} typeerror undefined is not a function
提问by phillis Peters
i am creating a chat application using socket.io and angularjs, when i run the app.js file using cmd, i get an error saying "app.configure(function){} typeerror undefined is not a function" what could be the problem?
我正在使用 socket.io 和 angularjs 创建一个聊天应用程序,当我使用 cmd 运行 app.js 文件时,我收到一条错误消息,提示“app.configure(function){} typeerror undefined is not a function”可能是什么问题?
my code looks like this:
我的代码是这样的:
var http = require('http');
var express = require('express'),
routes = require('./routes'),
socket = require('./routes/socket.js');
app = module.exports.app = express();
var server = http.createServer(app);
var io = require('socket.io').listen(server); //pass a http.Server instance
server.listen(80);
// Configuration
// 配置
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.set('view options', {
layout: false
});
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(express.static(__dirname + '/public'));
app.use(app.router);
});
回答by phillis Peters
i was using Express 4.0 in which configure was removed. See http://expressjs.com/guide/migrating-4.html#other-changesSimple mistake took me an hour to realise.
我正在使用 Express 4.0,其中删除了配置。请参阅http://expressjs.com/guide/migrating-4.html#other-changes简单的错误花了我一个小时才意识到。