nodejs 连接mongodb时提示Cannot read property ‘DEFAULT_PORT’ of undefined

作者: 淡蓝海域 分类: Nodejs 发布时间: 2018-03-21 07:58

启动服务的时候, 在db.js中报错:

module.exports = new Db(settings.db, new Server(settings.host, Connection.DEFAULT_PORT, {}));
Cannot read property ‘DEFAULT_PORT’ of undefined。

解决方法:

英文版:

Hello. I’ve checked this problem.

“Connection” form lib of “mongodb” has been removed in the latest version 2.0.42. When I created this project, mongodb version is 0.9.x. So you can set DEFAULT_PORT by your own.

I have updated the project. And in fact I set this argument in “./setting.js”. Usually the port of connection to mongodb is 27017. It depends.

At last, do not foget booting up your Mongodb and read it’s log. The log is the important road to lead everythings to be fine.

中文版:

“mongodb”的“Connection”形式的lib在最新版本2.0.42中已被删除。 当我创建这个项目时,mongodb版本是0.9.x. 所以可以自己设置DEFAULT_PORT。

通常连接到mongodb的默认端口是27017。所以可以直接改成 27017 !

参考地址:https://github.com/PaladinTyrion/nodejs_BYVoid_demo/issues/1

如果觉得我的文章对您有用,请随意打赏。您的支持将鼓励我继续创作!