我有以下文件:
var express = require('express'),
http = require('http'),
app = express(),
httpServer = http.createServer(app);
app.configure(function () {
app.set('port', 3000);
app.use(express.static(__dirname + '/public'));
});
httpServer.listen(app.get('port'), function () {
console.log("Express server listening on port %s.", httpServer.address().port);
});但是,这会产生以下错误:
C:\var\www\stage.mayfieldafc.com>nodemon http.js
18 Jul 01:19:29 - [nodemon] v1.2.1
18 Jul 01:19:29 - [nodemon] to restart at any time, enter `rs`
18 Jul 01:19:29 - [nodemon] watching: *.*
18 Jul 01:19:29 - [nodemon] starting `node http.js`
C:\var\www\stage.mayfieldafc.com\http.js:8
app.configure(function () {
^
TypeError: Object function (req, res, next) {
app.handle(req, res, next);
} has no method 'configure'
at Object.<anonymous> (C:\var\www\stage.mayfieldafc.com\http.js:8:5)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:906:3
18 Jul 01:19:29 - [nodemon] app crashed - waiting for file changes before starting...在安装了nodemon和express之后,我可以看到node_modules中的两个文件夹
另外,当控制台记录express的返回时,我看到它正确地加载了模块。
如何验证我的节点安装?或者最好还是修好它。
发布于 2014-07-18 00:20:26
特快4号不再有app.configure()了。请参见从Express 3迁移到Express 4的维基。
https://stackoverflow.com/questions/24815094
复制相似问题