mongodb kerberos 对等依赖

mongodb kerberos peer dependency

尝试全局安装 mongodb 或 mongoose 会导致缺少对 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.

有谁知道如何解决这个问题?如果您手动安装,那么您必须在每次更新时都执行此操作。

另外,我找不到报告错误的地方...

我只需要 运行 npm install --save kerberos mongodb 就可以在我的项目中成功安装 mongodb。我假设你也可以在全球范围内这样做,但可能还有其他问题。

来自 mongodb NPM package 文档:

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.

它继续提供以下步骤来诊断 UNIX-based 操作系统上的问题:

如果您没有构建要素,它将无法构建。在 linux 的情况下,您将需要 gcc 和 g++,node.js 以及所有 headers 和 python。找出缺失内容的最简单方法是尝试构建 kerberos 项目。您可以通过执行以下步骤来完成此操作。

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

如果所有步骤都完成,您就安装了正确的工具链。如果你发现 node-gyp not found 你需要在全局安装它。

npm install -g node-gyp

如果正确编译并且 运行s 测试你是黄金。我们现在可以尝试通过执行以下命令来安装 mongod driver。

cd yourproject
npm install mongodb --save

如果仍然失败,下一步是检查 npm 日志。 Re运行 命令,但在本例中为详细模式。

npm --loglevel verbose install mongodb

这将打印出 npm 在尝试安装模块时执行的所有步骤。

其他可能的问题:

您的 python 安装可能被冲洗掉,导致 gyp 中断。我总是建议您首先通过尝试在有问题的服务器上构建节点本身来测试您的部署环境,因为这应该会发现损坏的包的任何问题(并且那里有很多损坏的包)。

另一件事是确保您的用户对安装节点模块的位置具有写入权限。

#!/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