2014-11-05 154 views
23

所以我試圖啓動我的節點應用程序,但是我的MongoDB安裝出現了一些錯誤。npm install mongoose失敗(kerberos和bson錯誤)

下面是我的開發環境的規格:=> 0.10.33(從nodejs.org安裝)

NPM => 1.4.28(從安裝的NodeJS

節點.ORG)

的git => 2.1.3(家釀)

mongodb => 2.6.5(自制)

如果它有所不同,我也使用Mean Stack Skeleton作爲教程的一部分。

概括地說,當我嘗試使用$ node app.js運行我的節點的應用程序,我得到以下回饋:

USER$ npm install mongoose 

> [email protected] 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 

> [email protected] 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 
[email protected] node_modules/mongoose 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] 
├── [email protected] ([email protected]) 
└── [email protected] ([email protected], [email protected], [email protected]) 

我檢查了builderror.log文件既kerberosbson模塊。但是,兩者都是空的。

我發現的一些研究表明,這個問題可能是因爲我的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,並試圖重新安裝模塊。我收到了同樣的錯誤。然而,不穩定的釋放反饋現在消失了。

回答

0

當我將cd'轉入kerberosbson目錄後,我使用命令$ node-gyp rebuild和節點模塊正確編譯。

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。這會爲您的Node.js應用程序創建名爲database的數據庫實例以連接到該實例。在您的原始終端窗口中,撥打$ node app.js,它將在沒有任何錯誤反饋的情況下運行。

我得到的錯誤不是Mongoose,MongoDB或其任何依賴項的錯誤構建的結果。錯誤是由於對MongoDB的誤解而導致的。 MongoDB必須作爲獨立於Node.js應用程序的進程運行,以便應用程序建立數據庫連接。

13

我已經通過將node-gyp安裝到全局範圍中解決了這個問題。希望能幫助到你。

$ npm install -g node-gyp 
+0

簡單,甜美,併爲我工作 – 2015-03-28 20:07:39

+0

非常感謝你 – Shreyas 2015-07-12 08:47:08

4

我只是卸載mongodb,然後成功安裝貓鼬。

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

有關在Linux發行人保證你有libkrb5-dev(或你的發行版的類似的包)安裝。這將處理與bson和kerberos的許多構建錯誤。

+2

完美工作 – MQ87 2015-09-18 12:36:09

+1

非常感謝,它的工作原理!我在Linux Mint 17中遇到了同樣的問題,並且解決了安裝該軟件包的問題:http://community.linuxmint.com/software/view/libkrb5-dev – iarroyo 2015-09-22 16:03:43

+1

使用此提示管理安裝Mongoose和MongoDB。我的終端仍然有一些警告,但沒有錯誤。 Ubuntu 14.04。 – piratemurray 2015-10-01 18:30:38

18

爲Ubuntu用戶,請先卸載moongose

npm uninstall mongoose --save 

然後安裝一個Kerberos更新

apt-get install libkrb5-dev 

然後 「安裝」 moongose再次

npm install mongoose --save 

我希望這可以幫助別人有。