首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >node.js不能正常工作,windows 7

node.js不能正常工作,windows 7
EN

Stack Overflow用户
提问于 2014-07-17 23:21:57
回答 1查看 58关注 0票数 0

我有以下文件:

代码语言:javascript
复制
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);
});

但是,这会产生以下错误:

代码语言:javascript
复制
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...

在安装了nodemonexpress之后,我可以看到node_modules中的两个文件夹

另外,当控制台记录express的返回时,我看到它正确地加载了模块。

如何验证我的节点安装?或者最好还是修好它。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-07-18 00:20:26

特快4号不再有app.configure()了。请参见从Express 3迁移到Express 4的维基

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24815094

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档