Forgive me for not reading the whole email and ignore this if I missed some critical information. But if you're tring to import a library in a view, you can't. Views must be side-effect free. Someone please correct me if I'm mistaken.
On May 24, 2013 4:36 AM, "Noah Diewald" <[email protected]> wrote: I have a design document where I'm trying to use commonjs in a view. At this point I've failed at trying to do the more complicated stuff that I intended to use this functionality for. I'm just trying to do something simple so that I can figure out why things aren't working for me. I'm following this wiki page fairly closely: https://wiki.apache.org/couchdb/CommonJS_Modules I have a views property that looks like this: views: { lib: { blue: "exports.ninenine = 99;" }, mymap: { map: "function (doc) {emit(require('../lib/blue').ninenine);}" } } I get errors that look like the following for every document in the log when attempting to run the view in the temporary view interface in futon: OS Process #Port<0.3115> Log :: function raised exception (new TypeError("mod.current is null", "/usr/share/couchdb/server/main.js", 1125)) with doc._id cccb3bb779549b28b2e48eb628934107 So it looks like relative paths don't work but if I use the property path as shown in the wiki: views: { lib: { blue: "exports.ninenine = 99;" }, mymap: { map: "function (doc) {emit(require('views/lib/blue').ninenine);}" } } I see this error in the log: OS Process #Port<0.3115> Log :: function raised exception (new TypeError("mod.current is null", "/usr/share/couchdb/server/main.js", 1125)) with doc._id cccb3bb779549b28b2e48eb628934107 I haven't seen if the errors are any different when I don't try to get the map function to run through futon but it isn't working either way. This looks to be particular to the views. I am using commonjs with both updates and validate_doc_update in the same design document and they are working properly. I am using the Arch Linux package couchdb 1.2.2-3. I hope I'm just making some type of dumb mistake that someone can point out. Any help would be very appreciated. Noah
