我试图运行我的koa app.js文件,但我无法让它工作。
这是我的app.js
var koa = require('koa'),
monk = require('monk'),
wrap = require('co-monk');
var db = monk("mongodb url here"),
collection = db.get('mycollection'),
transactions = wrap(collection);
var app = koa();
app.use(function*(){
var res = yield transactions.find({});
console.log(res);
});
app.listen(3000);
这是我得到的错误:
TypeError: Cannot read property 'name' of undefined
at makeSkinClass (/home/ric/node_modules/mongoskin/lib/utils.js:33:43)
at Object.<anonymous> (/home/ric/node_modules/mongoskin/lib/grid.js:6:35)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/ric/node_modules/mongoskin/lib/db.js:22:16)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/ric/node_modules/mongoskin/lib/mongo_client.js:5:14)
我还是Koa,nodejs的新手,所以我很难搞清楚这一点。任何帮助都会很棒!