【问题标题】:I get "Incorrect argument" error when i try to run a simple test on couchbase nodejs server当我尝试在 couchbase nodejs 服务器上运行一个简单的测试时,我得到“不正确的参数”错误
【发布时间】:2015-01-19 14:55:48
【问题描述】:
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

【问题讨论】:

  • 你在哪里(哪一行)得到错误?
  • 我编辑了关于完整错误的问题
  • 根据文档:github.com/couchbase/couchnode#introduction 看起来 new couchbase.Cluster('127.0.0.1:8091'); 应该是 new couchbase.Cluster();

标签: javascript node.js couchbase


【解决方案1】:

连接到集群的“规范”格式是couchbase://host,在您的情况下,hostlocalhost

根据您使用的版本,可能已经添加了更新的增强功能以​​允许常见的host:8091 反模式,但仍然是不正确的。

如果您升级到较新的版本,您的代码可能仍然可以工作 - 但您仍应使用 couchbase:// 变体(不带端口)。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-08-18
    • 1970-01-01
    • 1970-01-01
    • 2017-01-19
    • 1970-01-01
    • 2020-07-06
    • 1970-01-01
    相关资源
    最近更新 更多