Error connecting to CouchBase from Node.js using Couchnode v.1.2.4

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

Attempting to connect to a CouchBase server using code in 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 I get 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 Information:

  • Running Couchbase version 2.5.1 on Mac (server is working fine)
  • Node Version 0.10.29 (latest version)

Note . We tried to search the CouchBase Bug Tracker: http://www.couchbase.com/issues/issues/?jql=text%20~%20%22typeError%22 if other people have the same error. Bad luck.

+2
source share
1
+4

All Articles