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...
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.
#!/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
Related
I've installed everything with homebrew on my mac.
$ which node
/opt/homebrew/bin/node
$ which npm
/opt/homebrew/bin/npm
$ npm -g ls
/opt/homebrew/lib
├── #unlighthouse/cli#0.4.9
├── npm#9.4.0
├── prisma#4.9.0
├── puppeteer#19.6.3
└── ts-node#10.9.1
but when I try to run
npx unlighthouse ...
It fails:
Failed to find a chrome / chromium binary to run.
Add the puppeteer dependency to your project to resolve.
Run the following: npm install -g puppeteer
it seems npm can't access/find globally installed package puppeteer
???
Im working with AWS-Amplify and just updated it's CLI to the latest version, and now NPM complains that there are unmet dependencies, though graphql is clearly installed at the right version. What am missing here? Thanks for any clarification!
$ npm list -g --depth 0
/usr/local/lib
├── #aws-amplify/cli#4.12.0
├── #vue/cli#4.0.5
├── browser-sync#2.26.7
├── firebase-tools#7.10.0
├── graphql#14.5.8
├── nodemon#2.0.2
├── npm#6.13.6
└── parcel-bundler#1.12.4
npm ERR! peer dep missing: graphql#^14.5.8, required by #graphql-toolkit/file-loading#0.9.0
npm ERR! peer dep missing: graphql#^14.2.0, required by relay-compiler#6.0.0
This happens when your node version is not latest or when the dependencies require a certain version of other npm. Just check if all the npm packages and node is of latest version.
I'm linking my-lib to see effects in my-app right away.
cd my-lib-folder
npm link
cd ../my-app-folder
npm link my-lib
This works as expected. Changes are picked up by my-app and I see the symlink in node_modules. My problem is that in my-app-folder/, npm list --link=true shows up empty. How can I get a list of the linked modules?
npm ls my_lib
my-app#3.1.0 /Users/path/my_project
└── UNMET DEPENDENCY my-lib#3.7.0
npm ERR! missing: my-lib#3.7.0, required by my-app#3.1.0
This happens both with Node 8 and 10 and their respective npm versions.
OK, I realized that my-lib was somehow linked globally
$ npm ls -g --link=true --depth=0
/Users/apth/.nvm/versions/node/v8.11.4/lib
└── my-lib#3.1.0 -> /Users/franzih/code/my-lib-folder
Unlinking it with npm unlink -g my-lib and linking it again worked and it now shows up as local link:
$ npm ls --link=true
my-app#3.1.0 /Users/path/code/my-app-folder
└─┬ my-app#3.7.0 -> /Users/path/.nvm/versions/node/v8.11.4/lib/node_modules/my-lib-folder
├─┬ https-proxy-agent#2.2.1
│ ├─┬ agent-base#4.2.1
│ │ └─┬ es6-promisify#5.0.0
│ │ └── es6-promise#4.2.4
│ └─┬ debug#3.1.0
│ └── ms#2.0.0
└── node-fetch#2.2.0
Now npm i does not overwrite the link anymore. All good.
In my case, "my-lib" was not linked globally, but I had to:
Uninstall it completely from "my-app" (npm uninstall my-lib)
npm link my-lib from "my-app", and then
Run npm install my-lib in "my-app"
Every other combination of steps did not work, and I did not find the uninstall or reinstall documented anywhere. Hope this helps anyone else running into this problem.
After npm install on clean environment, I get following problem with b package:
npm ls b
a#2.0.6
├── b#3.0.0
├─┬ c#3.0.1
│ └── UNMET DEPENDENCY b#^1.0.0
└─┬ d#4.1.1
└─┬ c#2.1.0
└── UNMET DEPENDENCY b#^1.0.0
npm ERR! missing: b#^1.0.0, required by c#3.0.1
npm ERR! missing: b#^1.0.0, required by c#2.1.0
This obviously causes errors, as package c needs b#^1.0.0, but receives b#3.0.0.
I struggled to force npm to install both versions as if they were different packages. Tried going through npm docs, package-locks, and shinkwrap, but with no success. How can I solve this problem?
Environment info:
OS: macOS High Sierra 10.13.4
npm: 6.10
node: v8.8.1
Playing around I noticed, that a lot of packages had UNMET DEPENDENCY. Following procedure fixed the problem:
rm -rf node_modules
npm cache clean --force
npm install
After cleaning npm cache the issue is completely resolved:
a#2.0.6
├── b#3.0.0
├─┬ c#3.0.1
│ └── b#^1.0.0
└─┬ d#4.1.1
└─┬ c#2.1.0
└── b#^1.0.0
Strange bug.
Hello I recently tried installing grunt-command line interface according to the instructions on their website using the node package manager command
sudo npm install -g grunt-cli
It didnt work and I got the following errors
/usr/local/bin/grunt -> /usr/local/lib/node_modules/grunt-cli/bin/grunt
npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/couch-login requires request#'~2.9.202' but will load
npm WARN unmet dependency /usr/local/lib/node_modules/npm/node_modules/request,
npm WARN unmet dependency which is version 2.30.0
grunt-cli#0.1.13 /usr/local/lib/node_modules/grunt-cli
├── resolve#0.3.1
├── nopt#1.0.10 (abbrev#1.0.5)
└── findup-sync#0.1.3 (lodash#2.4.1, glob#3.2.11)
➜ ~
I'm not sure how i update this dependancy. Can anyone shed any light on this?
Try the following:
npm cache clean
npm install -g npm (update npm)
reinstall node.js completely (if all fails).
Please let me know if this works.