MongoDB:\ lib \ server.js:235 process.nextTick getaddrinfo ENOTFOUND错误 [英] MongoDB: \lib\server.js:235 process.nextTick getaddrinfo ENOTFOUND error

查看:87
本文介绍了MongoDB:\ lib \ server.js:235 process.nextTick getaddrinfo ENOTFOUND错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是NodeJS的入门者,当我在控制台中运行node MainApp.js时,出现此错误:

I'm a begginer in NodeJS and when i run node MainApp.js in console I get this error:

C:\Assigment 2 (NodeJS)\node_modules\mongodb\lib\server.js:235
        process.nextTick(function() { throw err; })
                                      ^
 Error: getaddrinfo ENOTFOUND . .:27017
    at errnoException (dns.js:26:10)
    at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:77:26)

我不知道这意味着什么.在MainApp内,我连接猫鼬:mongoose.connect("./DataBase");,其中数据库是我运行mongod --dbpath "C:\[...]\DataBase的文件夹.数据库服务器似乎成功启动,控制台打印:[...] waiting for connections on port 27017.

I don't know what this means. Inside MainApp I connect mongoose: mongoose.connect("./DataBase"); where DataBase is the folder where I run mongod --dbpath "C:\[...]\DataBase. The database server seems to start successfully, the console printing: [...] waiting for connections on port 27017.

server.js第231-236行:

server.js lines 231-236:

// Try to callback
      try {
        callback(err);
      } catch(err) {
        process.nextTick(function() { throw err; })
      }

软件包版本: 表达":〜4.13.1", "mongodb":〜2.1.0", 猫鼬":〜4.3.1"

Package versions: "express": "~4.13.1", "mongodb": "~2.1.0", "mongoose": "~4.3.1"

推荐答案

我还不了解整个过程,但是我希望这个答案能提供一些见识:

I do not understand the whole process yet, but I hope this answer will provide some insight:

似乎在不启动数据库的情况下运行nodenpm start 会返回此错误.

It seems that running node or npm start without starting up the database returns this error.

如果数据库已启动,则进行更改 mongoose.connect("./DataBase");(先前导致该错误) mongoose.connect('mongodb://localhost/database');修复了该问题.

If database is started, then changing mongoose.connect("./DataBase"); (which previously caused the error) to mongoose.connect('mongodb://localhost/database');fixes the issue.

从直觉上讲,这似乎只是MongoDB在找不到服务器使用的数据库时返回的错误,但这可能不是问题的准确描述.

Intuitively this seems to simply be the error MongoDB returns when it can't find the database used by the server, however this might not be the precise description of the issue.

如果有人可以提供有关该问题的进一步见解,将不胜感激.

If someone can provide further insight into the problem, such help would be appreciated.

这篇关于MongoDB:\ lib \ server.js:235 process.nextTick getaddrinfo ENOTFOUND错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆