npm安装猫鼬失败(kerberos和bson错误) [英] npm install mongoose fails (kerberos and bson errors)

查看:259
本文介绍了npm安装猫鼬失败(kerberos和bson错误)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我试图启动我的节点应用程序,但是我的MongoDB安装中出现了一些错误.

以下是我的开发环境的规范:

节点=> 0.10.33 (从nodejs.org安装)

npm => 1.4.28 (从nodejs.org安装)

git => 2.1.3 (自制)

mongodb => 2.6.5 (自制)

如果有所作为,我还将在教程中使用平均堆栈骨架.

简而言之,当我尝试使用$ node app.js运行节点应用程序时,得到以下反馈:

USER$ npm install mongoose

> kerberos@0.0.4 install /Users/USER/APP/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)

  CXX(target) Release/obj.target/kerberos/lib/kerberos.o
  CXX(target) Release/obj.target/kerberos/lib/worker.o
  CC(target) Release/obj.target/kerberos/lib/kerberosgss.o
  CC(target) Release/obj.target/kerberos/lib/base64.o
  CXX(target) Release/obj.target/kerberos/lib/kerberos_context.o
  SOLINK_MODULE(target) Release/kerberos.node
  SOLINK_MODULE(target) Release/kerberos.node: Finished

> bson@0.2.15 install /Users/USER/APP/node_modules/mongoose/node_modules/mongodb/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)

  CXX(target) Release/obj.target/bson/ext/bson.o
  SOLINK_MODULE(target) Release/bson.node
  SOLINK_MODULE(target) Release/bson.node: Finished
mongoose@3.8.18 node_modules/mongoose
├── regexp-clone@0.0.1
├── muri@0.3.1
├── sliced@0.0.5
├── hooks@0.2.1
├── mpath@0.1.1
├── mpromise@0.4.3
├── ms@0.1.0
├── mquery@0.8.0 (debug@0.7.4)
└── mongodb@1.4.12 (readable-stream@1.0.33, kerberos@0.0.4, bson@0.2.15)

我检查了kerberosbson模块的builderror.log文件.但是,两者都是空的.

我发现的一些研究表明,问题可能是因为我的node-gyp安装没有相应的binding.gyp文件.

还尝试在Node.js项目文件夹中运行$ node-gyp configure.这是我收到的错误:

gyp: binding.gyp not found (cwd: /Users/USER/APP) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/node-gyp/lib/configure.js:343:16)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Darwin 12.5.0
gyp ERR! command "node" "/usr/local/bin/node-gyp" "configure"
gyp ERR! cwd /Users/USER/APP
gyp ERR! node -v v0.10.33
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok

我为什么遇到这些问题的任何想法?

在我的app.js文件中设置端口以将端口设置为Express服务器正在侦听的端口(duh)之后,我收到更多反馈,表明我正在使用Mongoose 3.9.4,这是mongoose的最新不稳定版本.因此,我在package.json中将模块设置为3.8.18,并尝试重新安装该模块.我收到了同样的错误.但是,不稳定的发布反馈现在消失了.

解决方案

在我cd进入kerberosbson目录之后,我使用了命令$ node-gyp rebuild和正确编译的节点模块. /p>

我的app.js文件,我调用了以下几行:

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

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

此端口号必须与数据库实例的端口唯一.

在单独的终端窗口中,运行$ mongod后台处理MongoDB.调用后,在另一个终端窗口中,调用$ mongo database.这将创建一个名为database的数据库实例供您的Node.js应用程序连接.在原始终端窗口中,调用$ node app.js,它将在没有任何错误反馈的情况下运行.

我得到的错误不是由于Mongoose,MongoDB或其任何依赖项的错误构建造成的.这些错误是由于对MongoDB的误解而导致的. MongoDB必须作为与Node.js应用程序分开的进程运行,以便该应用程序建立数据库连接.

So I'm attempting to launch my node app, but there's a few errors arising from my MongoDB installation.

Here are the specs for my dev environment:

node => 0.10.33 (installed from nodejs.org)

npm => 1.4.28 (installed from nodejs.org)

git => 2.1.3 (homebrewed)

mongodb => 2.6.5 (homebrewed)

If it makes a difference, I am also using the Mean Stack Skeleton as part of a tutorial.

In a nutshell, when I try to run my node app using $ node app.js, I get the following feedback:

USER$ npm install mongoose

> kerberos@0.0.4 install /Users/USER/APP/node_modules/mongoose/node_modules/mongodb/node_modules/kerberos
> (node-gyp rebuild 2> builderror.log) || (exit 0)

  CXX(target) Release/obj.target/kerberos/lib/kerberos.o
  CXX(target) Release/obj.target/kerberos/lib/worker.o
  CC(target) Release/obj.target/kerberos/lib/kerberosgss.o
  CC(target) Release/obj.target/kerberos/lib/base64.o
  CXX(target) Release/obj.target/kerberos/lib/kerberos_context.o
  SOLINK_MODULE(target) Release/kerberos.node
  SOLINK_MODULE(target) Release/kerberos.node: Finished

> bson@0.2.15 install /Users/USER/APP/node_modules/mongoose/node_modules/mongodb/node_modules/bson
> (node-gyp rebuild 2> builderror.log) || (exit 0)

  CXX(target) Release/obj.target/bson/ext/bson.o
  SOLINK_MODULE(target) Release/bson.node
  SOLINK_MODULE(target) Release/bson.node: Finished
mongoose@3.8.18 node_modules/mongoose
├── regexp-clone@0.0.1
├── muri@0.3.1
├── sliced@0.0.5
├── hooks@0.2.1
├── mpath@0.1.1
├── mpromise@0.4.3
├── ms@0.1.0
├── mquery@0.8.0 (debug@0.7.4)
└── mongodb@1.4.12 (readable-stream@1.0.33, kerberos@0.0.4, bson@0.2.15)

I checked the builderror.log files for both the kerberos and bson modules. However, both are empty.

Some research I have found suggests that the issue might be because my node-gyp installation does not have a corresponding binding.gyp file.

Also tried running $ node-gyp configure inside my Node.js project folder. And this is the error I received:

gyp: binding.gyp not found (cwd: /Users/USER/APP) while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/node-gyp/lib/configure.js:343:16)
gyp ERR! stack     at ChildProcess.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:810:12)
gyp ERR! System Darwin 12.5.0
gyp ERR! command "node" "/usr/local/bin/node-gyp" "configure"
gyp ERR! cwd /Users/USER/APP
gyp ERR! node -v v0.10.33
gyp ERR! node-gyp -v v1.0.2
gyp ERR! not ok

Any ideas why I am having these issues?

EDIT: After setting the port in my app.js file to set the port to the same one that the Express server is listening on (duh), I get more feedback indicating that I was using Mongoose 3.9.4, which is the latest unstable release of mongoose. So I set the module to 3.8.18 in my package.json and attempted to reinstall the module. I received the same errors. However, the unstable release feedback is gone now.

解决方案

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.

这篇关于npm安装猫鼬失败(kerberos和bson错误)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆