Error Connecting to CouchBase from Node.js using Couchnode module v.1.2.4

旧街凉风 提交于 2019-12-19 10:08:37

问题


Using https://github.com/couchbase/couchnode @v.1.2.4

Attempting to connect to CouchBase server using the code in the README

var couchbase = require('couchbase');
var cluster = new couchbase.Cluster();
var db = cluster.openBucket('default');

db.set('testdoc', {name:'Frank'}, function(err, result) {
  if (err) throw err;

  db.get('testdoc', function(err, result) {
    if (err) throw err;

    console.log(result.value);
    // {name: Frank}
  });
});

but am getting the following error:

db.js:2
var cluster = new couchbase.Cluster();
              ^
TypeError: undefined is not a function
    at Object.<anonymous> (/Users/n/code/time/test/db.js:2:15)
    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:906:3
npr:time n$ 

Additional details:

  • Running Couchbase Version 2.5.1 on Mac (server appears to be working fine)
  • Node Version 0.10.29 (latest)

Note: We tried searching on the CouchBase Bug Tracker: http://www.couchbase.com/issues/issues/?jql=text%20~%20%22typeError%22 in case other people were having the same error. No luck.


回答1:


The "solution" was to use the "Developer Preview" of Couchbase

npm install couchbase@2.0.0-dp1

Then all the examples on https://github.com/couchbase/couchnode worked as expected.

See: http://blog.couchbase.com/nodejs-sdk-200-developer-preview



来源:https://stackoverflow.com/questions/24698159/error-connecting-to-couchbase-from-node-js-using-couchnode-module-v-1-2-4

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!