使用 Couchnode 模块 v.1.2.4 从 Node.js 连接到 CouchBase 时出错 [英] Error Connecting to CouchBase from Node.js using Couchnode module v.1.2.4
问题描述
使用 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
然后 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-开发者预览
这篇关于使用 Couchnode 模块 v.1.2.4 从 Node.js 连接到 CouchBase 时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!