对node.js和mongodb的n00b位。当我尝试使用mongodb和mongoose设置项目时,我在需要mongoose模块后仍然遇到错误。不知道发生了什么,希望节点有更好的调试器。
我启动mongod并用节点启动app.js。然后我收到了这个错误。
/home/archie/Development/working/nodepad/node_modules/mongoose/node_modules/mongodb/lib/mongodb/bson/bson.js:422
" var options_array = [];
node.js:134
throw e; // process.nextTick error, or 'error' event on first tick
^
TypeError: Cannot read property 'ObjectID' of undefined
at Object.<anonymous> (/home/archie/Development/working/nodepad/node_modules/mongoose/lib/drivers/node-mongodb-native/objectid.js:6:43)
at Module._compile (module.js:411:26)
at Object..js (module.js:417:10)
at Module.load (module.js:343:31)
at Function._load (module.js:302:12)
at require (module.js:355:19)
at Object.<anonymous> (/home/archie/Development/working/nodepad/node_modules/mongoose/lib/types/objectid.js:12:18)
at Module._compile (module.js:411:26)
at Object..js (module.js:417:10)
at Module.load (module.js:343:31)
这是我的代码
var express = require('express');
var app = module.exports = express.createServer();
var mongoose = require('mongoose') ;
// Configuration
app.configure(function(){
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(__dirname + '/public'));
});
app.configure('development', function(){
app.use(express.logger());
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});
app.get('/', function(req, res){
res.render('index', {
title: 'Express'
});
});
app.listen(3000);
console.log("Express server listening on port %d in %s mode", app.address().port,
app.settings.env);
任何帮助都会很棒,谢谢。