var couchbase = require("couchbase");
var cluster = new couchbase.Cluster('127.0.0.1:8091');
var bucket = cluster.openBucket('beer-sample', function(err) {
if (err) {
throw err;
}
bucket.get('aass_brewery-juleol', function(err, result) {
if (err) {
throw err;
}
var doc = result.value;
console.log(doc.name + ', ABV: ' + doc.abv);
doc.comment = "Random beer from Norway";
bucket.replace('aass_brewery-juleol', doc, function(err, result) {
if (err) {
throw err;
}
console.log(result);
process.exit(0);
});
});
});
这是我的档案。这是这里的例子:http://docs.couchbase.com/developer/node-2.0/hello-couchbase.html
所以当我尝试使用" nodejs test1.js"运行服务器时我得到"不正确的参数"错误。
在bucket.js,module.js和cluster.js中进入node_modules / couchbase / lib /
我已经安装了couchbase,我安装了完整的nodejs。我是新手,我无法理解我的错误在哪里。也许有一些版本的基础或节点版本我不知道。
这是我进入终端的完整错误:
Error: Incorrect argument
at New Bucket (home/anton/node_modules/couchbase/lib/bucket.js:213:16)
at Object<anonymus> (home/anton/PhpstormProjects/couchbase/test1.js:6:22)
at Cluster.openBucket (home/anton/node_modules/couchbase/lib/cluster.js:37:10)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:902:3
答案 0 :(得分:0)
用于连接群集的“规范”格式为couchbase://host
,其中主机为localhost
。
根据您使用的版本,可能添加了较新的增强功能以允许常见的host:8091
反模式,但仍然不正确。
如果您升级到更新版本,您的代码仍然可以正常工作 - 但您仍然应该使用couchbase://
变体(没有端口)。