CNode

Cannot read property 'DEFAULT_PORT' of undefined

问答
MMartinHuangJing发布于11 年前最后回复11 年前4 回复10708 浏览0 收藏

这个是要指定数据库端口吗?mongodb怎么指定啊

Cannot read property 'DEFAULT_PORT' of undefined

查看回复

回复 (4)

X
xiaoxi--#1·11 年前

刚才也遇见了同样的问题,我这边原因可能是npm install mongodb安装不完整 随后我从别的项目中拷了一个,然后项目就可以正常启动啦

M
MartinHuangJing#2·11 年前

//db.js var setting = require('../setting.js'); var Db = require('mongodb').Db; var Connection = require('mongodb').Connection; var Server = require('mongodb').Server; module.exports = new Db(setting.db,new Server(setting.host, Connection.DEFAULT_PORT,{}),{safe:true});

L
leapon#3·11 年前

你的 Connection object 是undefined。和 数据库端口 没有关系。

W
weierbufan#4·11 年前

这是要指定你要连接的mongodb数据库服务器的默认端口号,所以把Connection.DEFAULT_PORT改成27017,就可以了。。。。

参与回复
登录后即可参与回复。登录