27

Trying to install mongodb or mongoose globally results in a missing peer dependency for Kerberos

Jamess-MacBook-Pro:ka2 jamessherry$ npm install -g mongodb
/usr/local/lib
└─┬ mongodb@2.0.48 
  └── UNMET PEER DEPENDENCY kerberos@~0.0

npm WARN EPEERINVALID mongodb-core@1.2.21 requires a peer of kerberos@~0.0 but none was installed.
Jamess-MacBook-Pro:ka2 jamessherry$ npm install -g mongodb
- nan@2.0.9 node_modules/mongodb/node_modules/kerberos/node_modules/nan
- kerberos@0.0.17 node_modules/mongodb/node_modules/kerberos
/usr/local/lib
└─┬ mongodb@2.0.48 
  └── UNMET PEER DEPENDENCY kerberos@~0.0

npm WARN EPEERINVALID mongodb-core@1.2.21 requires a peer of kerberos@~0.0 but none was installed.
Jamess-MacBook-Pro:ka2 jamessherry$ npm install -g mongoose
/usr/local/lib
└─┬ mongoose@4.2.5 
  ├── async@0.9.0 
  ├── bson@0.4.19 
  ├── hooks-fixed@1.1.0 
  ├── kareem@1.0.1 
  ├─┬ mongodb@2.0.48 
  │ ├── es6-promise@2.1.1 
  │ ├── UNMET PEER DEPENDENCY kerberos@~0.0
  │ ├── mongodb-core@1.2.21 
  │ └─┬ readable-stream@1.0.31 
  │   ├── core-util-is@1.0.1 
  │   ├── inherits@2.0.1 
  │   ├── isarray@0.0.1 
  │   └── string_decoder@0.10.31 
  ├── mpath@0.1.1 
  ├── mpromise@0.5.4 
  ├─┬ mquery@1.6.3 
  │ ├── bluebird@2.9.26 
  │ └── debug@2.2.0 
  ├── ms@0.7.1 
  ├── muri@1.0.0 
  ├── regexp-clone@0.0.1 
  └── sliced@0.0.5 

npm WARN EPEERINVALID mongodb-core@1.2.21 requires a peer of kerberos@~0.0 but none was installed.

Does anyone know how to go about fixing that? If you manually install then you have to do that on every update.

Also, I can't find a place to report the bug...

user1775718
  • 1,499
  • 2
  • 19
  • 32
  • Try installing them locally instead of globally. Global really only make sense for command line utilities anyway. – JohnnyHK Nov 11 '15 at 04:35
  • 1
    I had this error also, I suggest you open an issue on JIRA [here](https://jira.mongodb.org/browse/NODE/?selectedTab=com.atlassian.jira.jira-projects-plugin:issues-panel) as they don't use Github to track issues which makes it more difficult to report bugs. Alternatively go to the gitter room [here](https://gitter.im/mongodb/node-mongodb-native). The author of nodejs drivers will answer questions on their. – simon-p-r Nov 11 '15 at 08:07
  • 2
    Have you tried just ignoring the warning? At least my code seems to be running fine so far without going through the obvious hassle of installing the kerberos module. My guess is the kerberos stuff is only used for authentication which you might not need depending on your use case. – mthierer Dec 21 '15 at 10:16

2 Answers2

28

I just had to run npm install --save kerberos mongodb to successfully install mongodb in my project. I assume you can do it globally as well, but there may be other issues.

From the mongodb NPM package docs:

The kerberos package is a C++ extension that requires a build environment to be installed on your system. You must be able to build node.js itself to be able to compile and install the kerberos module. Furthermore the kerberos module requires the MIT Kerberos package to correctly compile on UNIX operating systems. Consult your UNIX operation system package manager what libraries to install.

It goes on to offer the following steps for diagnosing the issue on UNIX-based operating systems:

If you don’t have the build essentials it won’t build. In the case of linux you will need gcc and g++, node.js with all the headers and python. The easiest way to figure out what’s missing is by trying to build the kerberos project. You can do this by performing the following steps.

git clone https://github.com/christkv/kerberos.git
cd kerberos
npm install

If all the steps complete you have the right toolchain installed. If you get node-gyp not found you need to install it globally by doing.

npm install -g node-gyp

If correctly compiles and runs the tests you are golden. We can now try to install the mongod driver by performing the following command.

cd yourproject
npm install mongodb --save

If it still fails the next step is to examine the npm log. Rerun the command but in this case in verbose mode.

npm --loglevel verbose install mongodb

This will print out all the steps npm is performing while trying to install the module.

Other possible issues:

Your python installation might be hosed making gyp break. I always recommend that you test your deployment environment first by trying to build node itself on the server in question as this should unearth any issues with broken packages (and there are a lot of broken packages out there).

Another thing is to ensure your user has write permission to wherever the node modules are being installed.

Shaun Scovil
  • 3,905
  • 5
  • 39
  • 58
  • Worked for me too. Thanks! – Cyph Nov 16 '15 at 05:33
  • Official driver installation informations here https://github.com/mongodb/node-mongodb-native#troubleshooting – thomas.g Nov 25 '15 at 08:42
  • The solution was surprisingly hard to find! I've been stuck with the "mongodb-core requires a peer of kerberos" error since last night – Boyan Mar 16 '16 at 12:15
  • UPDATED Official installation information here - http://mongodb.github.io/node-mongodb-native/2.0/getting-started/installation-guide/#troubleshooting `This tells you that the driver could not resolve its peerDependency. However don’t worry – if you do not intend to use kerberos, you can safely ignore the NPM warning above.` – Vlad Holubiev Nov 17 '16 at 19:38
0
#!/bin/bash
#My quasi bash script. This worked for Ubuntu v14.04 using Node.js v5.1.0 and mongodb v3.0.7
clear

# prerequisites for building node.js from its source files
sudo apt-get install clang-3.5 make gcc g++ libssl-dev libkrb5-dev

# where you extracted the latest stable release. https://github.com/nodejs/node/releases
cd ~/Downloads/node
# git clone https://github.com/nodejs/node # this does NOT work because it gets a beta/pre release.
./configure
# "-j 3" uses two processors for the compile on a duo core processor. 3 means 2 for some reason.
make -j 3
sudo make install
make doc
make test

# prerequisites for being able to use '$ npm install mongodb'
cd ~
sudo npm install -g node-gyp
sudo npm install -g kerberos

# npm mongodb will NOT install globally '-g'. Therefore you have to install local to each project.
#cd to/your/project/directory
# make sure you are in your project directory root and that the "node_modules" directory is not 'root:root'
npm install mongodb --save
Rick
  • 572
  • 1
  • 7
  • 21
  • I did it like that because it is a bash script explained with comments that will be needed in the bash file. Makes for an easy copy-paste. If I change it, it will be easier to read and not as easy to use. – Rick Feb 18 '16 at 23:21