簡體   English   中英

當我嘗試在Couchbase Node.js服務器上運行簡單測試時,出現“參數錯誤”錯誤

[英]I get “Incorrect argument” error when i try to run a simple test on couchbase nodejs server

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 /

我已經安裝了ouchbase,並且已經安裝了完整的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

用於連接到集群的“規范”格式為couchbase://host ,其中您的主機localhost

根據您使用的版本,可能已添加了較新的增強功能,以允許使用通用host:8091反模式,但仍然不正確。

如果升級到較新的版本,您的代碼可能仍然可以工作-但您仍應使用couchbase://變體(不帶端口)。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM