本文介绍了MongoSkin“无法读取未定义的属性'应用'"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在NodeJS中使用MongoSkin,并且我有以下代码:
I'm trying to use MongoSkin in NodeJS, and I have this code:
var mongoskin = require('mongoskin');
var db = mongoskin.db("mongodb://localhost:27017/database");
var collection = db.collection('test');
collection.find().toArray(function(err, items) {
db.close();
});
但是它返回此错误:
TypeError: Cannot read property 'apply' of undefined
at EventEmitter.<anonymous> (C:\Users\user\node_modules\mongoskin\lib\collection.js:51:21)
at Object.onceWrapper (events.js:273:13)
at EventEmitter.emit (events.js:182:13)
at C:\Users\user\node_modules\mongoskin\lib\utils.js:134:27
at result (C:\Users\user\node_modules\mongodb\lib\utils.js:414:17)
at executeCallback (C:\Users\user\node_modules\mongodb\lib\utils.js:406:9)
at err (C:\Users\user\node_modules\mongodb\lib\operations\mongo_client_ops.js:286:5)
at connectCallback (C:\Users\user\node_modules\mongodb\lib\operations\mongo_client_ops.js:241:5)
at process.nextTick (C:\Users\user\node_modules\mongodb\lib\operations\mongo_client_ops.js:463:7)
at process._tickCallback (internal/process/next_tick.js:61:11)
我也尝试使用此代码
var mongoskin = require('mongoskin');
var db = mongoskin.db("mongodb://localhost:27017/database");
db.bind('test');
db.test.find().toArray(function(err, array) {
db.close();
});
我正在查看 https://www.npmjs.com/package/mongoskin 中的示例
推荐答案
这是依赖性问题,最新的mongoskin是2.1.0,它取决于mongodb2.x.如果使用最新的mongodb 3.x,则会发生错误.
It is dependency problem, latest mongoskin is 2.1.0, it depends on mongodb 2.x.Error occurred if using the latest mongodb 3.x.
这篇关于MongoSkin“无法读取未定义的属性'应用'"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!