不能找到方法,我有节点的js代码:在快递
var express = require('express')
, app = express.createServer();
app.use(express.bodyParser());
app.post('/', function(request, response){
console.log(request.body); // your JSON
response.send(request.body); // echo the result back
});
app.listen(3000);
,当我跑我得到这样的错误:
, app = express.createServer();
^
TypeError: Object function createApplication() {
var app = function(req, res, next) {
app.handle(req, res, next);
};
mixin(app, proto);
mixin(app, EventEmitter.prototype);
app.request = { __proto__: req, app: app };
app.response = { __proto__: res, app: app };
app.init();
return app;
} has no method 'createServer'
at Object.<anonymous> (/Users/anto_belgin/programs/node/appleconnect.js:2:19)
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:902:3
我已经安装使用express
:
npm install express
有什么我需要做的让它工作?
注:'express.createServer()'是[弃用与3.X(https://github.com/ strongloop/express/wiki/Migrating-from-2.x-to-3.x#changed)和[用4.x删除](https://github.com/strongloop/express/wiki/Migrating-from-3 .X到4.x的#expresscreateserver)。 – 2014-09-19 05:20:37