Node.js issue with mongodb



我在项目的最顶层目录中运行了node server.js
这就是我得到的错误:

connect.multipart() will be removed in connect 3.0
visit https://github.com/senchalabs/connect/wiki/Connect-3.0 for alternatives
connect.limit() will be removed in connect 3.0
The magic happens on port 8080
events.js:72
        throw er; // Unhandled 'error' event
              ^
Error: failed to connect to [your_database_here:27017]
    at null.<anonymous> (/home/ajay/Desktop/easy-node-authentication-facebook/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/server.js:549:74)
    at emit (events.js:106:17)
    at null.<anonymous> (/home/ajay/Desktop/easy-node-authentication-facebook/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection_pool.js:150:15)
    at emit (events.js:98:17)
    at Socket.<anonymous> (/home/ajay/Desktop/easy-node-authentication-facebook/node_modules/mongoose/node_modules/mongodb/lib/mongodb/connection/connection.js:533:10)
    at Socket.emit (events.js:95:17)
    at net.js:833:16
    at process._tickCallback (node.js:419:13)

我已经安装了mongodb,当我在浏览器中打开localhost:27017时,它显示It looks like you are trying to access MongoDB over HTTP on the native driver port.。确切的错误在哪里?

我建议您使用"mongoose"从节点连接mongodb。以下是执行此操作的示例代码。

var mongoose=require('mongoose'),
    db = 'mongodb://localhost/test';
mongoose.connect(db);
//and your code goes here

您必须安装节点模块"mongoose"。阅读猫鼬的文档。

最新更新