npm install mongoose fails (kerberos and bson errors)

丶灬走出姿态 提交于 2019-12-03 09:37:15

For anyone on a Linux distro ensure you have libkrb5-dev (or your distro's similar package) installed. This will take care of many build errors with bson and kerberos.

For ubuntu users, first uninstall moongose

npm uninstall mongoose --save

then install the a kerberos update

apt-get install libkrb5-dev

then "install" moongose again

npm install mongoose --save

I hope this helps somebody there.

I've fixed this by installing node-gyp into the global scope. Hope it helps.

$ npm install -g node-gyp 

I just uninstall mongodb and then install mongoose successfully.

npm uninstall mongodb --save
npm install mongoose --save

After I cd'd into the kerberos and bson directories, I used the command $ node-gyp rebuild and the node modules compiled correctly.

My app.js file, I called the following lines:

var app = express();
...
var Mongoose = require('mongoose');
var db = Mongoose.createConnection('localhost','database');

// all environments
app.set('port', process.env.PORT || 3000);

This port number must be unique from the port of your database instance.

In a separate terminal window, run $ mongod to spool up your MongoDB. Once it's called, in yet another terminal window, you call $ mongo database. This creates the database instance called database for your Node.js app to connect to. In your original terminal window, call $ node app.js and it will run without any error feedback.

The errors I was getting were not the result of an incorrect build of Mongoose, MongoDB or any of their dependencies. The errors were a result of a misconception about MongoDB. MongoDB must be running as a process separate to your Node.js app in order for the app to make a database connection.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!