Couchbase node.js模块

我正在使用节点v.0.10.33 couchbase,节点模块v.2.0.0和couchbase-server-v.3.0.1

var couchbase = require("couchbase"); // Connect to Couchbase Server var cluster = new couchbase.Cluster('10.50.10.31:8091'); var bucket = cluster.openBucket('beer-sample', function(err) { if (err) { // Failed to make a connection to the Couchbase cluster. throw err; } // Retrieve a document bucket.get('aass_brewery-juleol', function(err, result) { if (err) { // Failed to retrieve key throw err; } var doc = result.value; console.log(doc.name + ', ABV: ' + doc.abv); // Store a document doc.comment = "Random beer from Norway"; bucket.replace('aass_brewery-juleol', doc, function(err, result) { if (err) { // Failed to replace key throw err; } console.log(result); // Success! process.exit(0); }); }); }); 

当我在同一台机器上运行上述程序,其中couchbase服务器安装其工作正常..用这一行

  var cluster = new couchbase.Cluster('127.0.0.1:8091'); 

但是,当我与另一个通过局域网连接的系统运行时,我得到networking错误。 用这条线

  var cluster = new couchbase.Cluster('10.50.10.31:8091'); 

这个错误…

 Couchbase Error : Network Failure 

也试过了

 var cluster = new couchbase.Cluster('couchbase://10.50.10.31') 

不工作…

 var cluster = new couchbase.Cluster('couchbase://localhost') 

正常工作…

我哪里错了,请帮助我…对错误抱歉。

按照Couchbase Node.js SDK文档 ,尝试创build这样的连接:

 var couchbase = require("couchbase"); var bucket = new couchbase.Connection({ 'bucket':'beer-sample', 'host':'10.50.10.31:8091' }, function(err) { if (err) { // Failed to make a connection to the Couchbase cluster. throw err; } // your code to work with bucket here... }); 

问题是用python和node-gyp

我已经升级了python

并重buildcouchbase模块

 cd path_to_nodejs_project/node_modules/coucbase/ node-gyp clean node-gyp configure node-gyp build 

这解决了我的问题