OS: Ubuntu 16.04
Couchbase version: Version: 4.5.1-2844 Enterprise Edition (build-2844)
Node version: v6.5.0 (not selectable in your list below)
Getting started for evaluation. I went through the install and setup without issue and have cloned try-cb. This is the result of ‘npm run start’:
(sosadmin) ~/wk/cliosoft/sosadmin/couchbase/try-cb $ npm run start
> try-cb@0.1.0 start /home/paul/wk/cliosoft/sosadmin/couchbase/try-cb
> node app.js
/home/paul/wk/cliosoft/sosadmin/couchbase/try-cb/node_modules/ottoman/lib/cbstoreadapter.js:33
throw new Error('The couchbase module version used by the application'
^
Error: The couchbase module version used by the application does not match Ottomans. Please explicitly pass the application couchbase module using `StoreAdapter.Couchbase`.
at new CbStoreAdapter (/home/paul/wk/cliosoft/sosadmin/couchbase/try-cb/node_modules/ottoman/lib/cbstoreadapter.js:33:13)
at Ottoman.set (/home/paul/wk/cliosoft/sosadmin/couchbase/try-cb/node_modules/ottoman/lib/ottoman.js:55:20)
at Object.<anonymous> (/home/paul/wk/cliosoft/sosadmin/couchbase/try-cb/model/user.js:3:16)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
at Module.require (module.js:483:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/home/paul/wk/cliosoft/sosadmin/couchbase/try-cb/model/auth.js:4:12)
at Module._compile (module.js:556:32)
at Object.Module._extensions..js (module.js:565:10)
at Module.load (module.js:473:32)
at tryModuleLoad (module.js:432:12)
at Function.Module._load (module.js:424:3)
As I’m just getting started I’ve no idea how to carry out the suggested fix and google has not been any help. Can anyone point me in the right direction?
Because of the internal dependancy between Ottoman.js and the Node.js SDK, and a quirk of how JavaScript performs object comparison, you must ensure that your applications Node.js SDK version matches the one Ottoman is using (or explicitly provide the right SDK to ottoman). In the first case, simply check the package.json for the version of Ottoman.js you are using, and then use the same version in your application. In the second case, simply replace:
ottoman.bucket = myBucket;
with the following instead:
// assumes couchbase is `require('couchbase')`
// assumes myBucket is your couchbase.Bucket object.
ottoman.store = new ottoman.CbStoreAdapter(myBucket, couchbase);
The package.json file for ottoman in node_modules shows a dependency on couchbase of: "couchbase": "~2.2.2"
Setting the couchbase version in the apps package.json to the same and doing a npm install to update the dependencies… couchbase updates to 2.2.5 (2.2.2 not available?). Running the app I still get the same error.
Alternatively, to solve this in code how would I do this? The urlshortener example code has:
ottoman.bucket = (new couchbase.Cluster(“couchbase://localhost”)).openBucket(“example”);
What should I replace this with? I tried this:
cluster = new couchbase.Cluster(“couchbase://localhost”);
bucket = cluster.openBucket(“example”);
ottoman.store = new ottoman.CbStoreAdapter(bucket, couchbase);
This got the code to run but only returned Cannot GET / when I hit the service. Given the rest of the code is as in the example I don’t think I’ve fixed it (just changed the symptom?)
You’re package.json version descriptor on your application should be "couchbase": "~2.2.5" to match the most current Ottoman.js version ( which should be `“ottoman”: “~1.0.4”). This should fix your versioning issue.
On your attempt for the other possible solution (specifying the couchbase package explicitly). You have done the correct instantiation, and the lack of any error messages from Ottoman indicates that it is working. It sounds like your application code may be at fault for the remaining issue. Cannot GET / indicates that there is no express route configured for your root. Can you post your application code to a Gist perhaps?
Thanks for the reply. I got the work-around method working… had a code issue (no really! ;-)) and the Windows 10 anniversery issue which was solved by going to 4.6. Fixing those two up and I have an api responding as expected. To improve my error handing in the future, is there a way to catch exceptions when opening connections to couchbase? ie. something like:
cluster = new couchbase.Cluster(“couchbase://localhost”, function(err) {
if (err) { console.log(“Can’t connect to couchbase: %s”, err) }
});
(and similarly for open bucket commands, etc)
btw - for completeness (and curiosity) I also tried to get the ottoman v couchbase versioning aligned but couldn’t solve this. Here’s what I tried…
The dependency in the ottoman (v1.0.4) package.json file lists a dependency (& optional dependency) on couchbase ~2.2.2. My first attempt at correcting this was to make my app have a dependency of ~2.2.2 in its package.json. When doing an npm install it installed the 2.2.5 version of couchbase. If I change the dependency in the app to ~2.2.5 as suggested it makes no difference. Is there a way to rebuild/make ottoman to use 2.2.5 rather 2.2.2? ie. can I update its package.json and rebuild that ‘module’?
Can you help me with this error? The couchbase module version used by the application does not match Ottomans. Please explicitly pass the application couchbase module usingStoreAdapter.Couchbase`.
I’m getting this error using the new version of Couchbase server 4.6 inside a Docker container.
My package.json: "dependencies": { "body-parser": "^1.16.1", "couchbase": "^2.3.0", "express": "^4.14.1", "ottoman": "^1.0.4" }
My app.js:
var express = require(‘express’)
var couchbase = require(‘couchbase’)
var bodyParser = require(‘body-parser’)
var ottoman = require(‘ottoman’)
This is due to a version missmatch between the Node.js SDK version installed with Ottoman, and the version you have installed locally for your application. The most compatible workaround is to tell Ottoman which version of the SDK it should use.
You can do that by replacing:
ottoman.bucket = bucket;
With:
ottoman.store = new ottoman.CbStoreAdapter(bucket, ottoman);
Its working well now i find out that when i print result to consul i can see one level deep of nested data in json,
country code is {“billingAddress”:{“postalCode”:“97203”,“country”:{"$ref":“Country”,"$id":“US”},“state”:“OR”,“line1”:“3942 NE Sixth St.”,“city”:“Portland”},“username”:“aaha123”,“updated”:“2015-07-24T15:59:26.000Z”,“firstName”:“Anne”,“created”:“2015-03-10T04:33:14.000Z”,“lastName”:“Aha”,“email”:“anne.aha@mail.com”}
and if i try to get json from billingAddress.country the i’m able to print data belong to country