nodejs版本v4.4.1 Python版本2.7.10 MongoDB服务已启动 Robomongo已连接上数据库并且已在代码中写好连接配置 npm install 下载依赖包之后,启动服务 然后,问题来了,如下: 求解怎么解决?求解怎么解决?求解怎么解决?
e:\wamp\www\magnet-zone-portal>node magnet-zone-portal-server.js server environment: dev e:\wamp\www\magnet-zone-portal\node_modules\express\lib\application.js:209 throw new TypeError(‘app.use() requires middleware functions’); ^
TypeError: app.use() requires middleware functions at EventEmitter.use (e:\wamp\www\magnet-zone-portal\node_modules\express\lib\application.js:209:11) at Object.<anonymous> (e:\wamp\www\magnet-zone-portal\magnet-zone-portal-server.js:65:5) at Module._compile (module.js:409:26) at Object.Module._extensions…js (module.js:416:10) at Module.load (module.js:343:32) at Function.Module._load (module.js:300:12) at Function.Module.runMain (module.js:441:10) at startup (node.js:139:18) at node.js:968:3
@ncuzp express是npm install下载的,提示是209行,下面是代码:
/**
- Proxy
Router#use()
to add middleware to the app router. - See Router#use() documentation for details.
- If the fn parameter is an express app, then it will be
- mounted at the route specified.
- @public */
app.use = function use(fn) { var offset = 0; var path = ‘/’;
// default path to ‘/’ // disambiguate app.use([fn]) if (typeof fn !== ‘function’) { var arg = fn;
while (Array.isArray(arg) && arg.length !== 0) {
arg = arg[0];
}
// first arg is the path
if (typeof arg !== 'function') {
offset = 1;
path = fn;
}
}
var fns = flatten(slice.call(arguments, offset));
if (fns.length === 0) { throw new TypeError(‘app.use() requires middleware functions’); }
// setup router this.lazyrouter(); var router = this._router;
fns.forEach(function (fn) { // non-express app if (!fn || !fn.handle || !fn.set) { return router.use(path, fn); }
debug('.use app under %s', path);
fn.mountpath = path;
fn.parent = this;
// restore .app property on req and res
router.use(path, function mounted_app(req, res, next) {
var orig = req.app;
fn.handle(req, res, function (err) {
req.__proto__ = orig.request;
res.__proto__ = orig.response;
next(err);
});
});
// mounted an app
fn.emit('mount', this);
}, this);
return this; };