使用Couchnode模块v.1.2.4连接到Node.js中的CouchBase时出错 [英] Error Connecting to CouchBase from Node.js using Couchnode module v.1.2.4

查看:236
本文介绍了使用Couchnode模块v.1.2.4连接到Node.js中的CouchBase时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 https://github.com/couchbase/couchnode @ v.1.2.4

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

尝试使用README中的代码连接到CouchBase服务器

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}
  });
});

但会收到以下错误:

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$ 

其他详细信息:


  • 在Mac上运行Couchbase版本2.5.1(服务器似乎工作正常)

  • 节点版本0.10.29(最新)

注意:我们尝试在CouchBase Bug Tracker上搜索: http://www.couchbase.com/issues/issues/?jql=text%20%20%22typeError%22 以防其他人有同样的错误。没有运气。

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.

推荐答案

解决方案是使用Couchbase的开发人员预览

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

npm install couchbase@2.0.0-dp1


$ b b

然后, https://github.com/couchbase/couchnode 上的所有示例都符合预期。

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

请参阅: http ://blog.couchbase.com/nodejs-sdk-200-developer-preview

这篇关于使用Couchnode模块v.1.2.4连接到Node.js中的CouchBase时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆