[英]node.js not functioning correctly, windows 7
I have the following file: 我有以下文件:
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);
});
However this gives the follow errors: 但是,这会产生以下错误:
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...
After installing both nodemon
and express
and I can see both folders inside of node_modules
在安装了nodemon
和express
,我可以在node_modules
看到两个文件夹
Also when console logging the return of express
I see that it has correctly loaded the module. 另外,当控制台记录express
的返回时,我看到它已经正确加载了模块。
How can I verify my node install? 如何验证我的节点安装? Or better still fix it. 或者最好还是修复它。
The method app.configure
has been removed from express 4
. app.configure
方法已从express 4
删除。 So now you have to say something like bellow. 因此,现在您必须说些类似的东西。
app.set('port', 3000);
app.use(express.static(__dirname + '/public'));
instead of 代替
app.configure(function () {
app.set('port', 3000);
app.use(express.static(__dirname + '/public'));
});
and there are many other changes has been made. 并进行了许多其他更改。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.