Open eethann opened 12 years ago
You're a brave man! :)
Sorry, require
in zappa 0.2.x is problematic because it's not the real deal. This is why we're moving to a @
-based API in 0.3.0 (whoa, déjà vu).
Until 0.3.0 is released, you can use this if you're having problems:
require('zappa') {require}, ->
HechoProvider = require('hechoprovider-mongodb').HechoProvider
Which is just a way to pass the real require to the zappa block, equivalent to the javascript:
require('zappa')({require: require}, function(){
var HechoProvider = require('hechoprovider-mongodb').HechoProvider;
});
As a side note, the following CoffeeScript lines are equivalent:
HechoProvider = require('hechoprovider-mongodb').HechoProvider
{HechoProvider} = require 'hechoprovider-mongodb'
Thanks for the amazingly quick response and the pointers...and the bit of mindbending coffeescript lesson at the end.
I added that line to the top of the app file, and while it is including just dandy now, it is still not finding the mongodb module, though the module is found in the basic Express app.
I'm definitely getting the sense that I may be a bit out of my depth here...but I'm game to keep on going. Any other ideas?
Is the express app in the exact same dir as the zappa one?
Also, in the same file where the zappa app is, if you take zappa out of the equation, does it work?
Ex.:
console.log require('hechoprovider-mongodb').HechoProvider
Doh. Just learned where npm modules are installed in Express projects.
Thanks.
Ethan On Sep 20, 2011 3:16 PM, "Maurice Machado" < reply@reply.github.com> wrote:
Is the express app in the exact same dir as the zappa one?
Also, in the same file where the zappa app is, if you take zappa out of the equation, does it work?
Ex.:
console.log require('hechoprovider-mongodb').HechoProvider
Reply to this email directly or view it on GitHub: https://github.com/mauricemach/zappa/issues/85#issuecomment-2148708
Hey there,
Thanks for Zappa. As a node/express/coffeescript n00b I should probably know better than to just jump right in to such an abstracted development system...but it's just too much fun!
That said, I'm having issues with requires in Zappa, specifically trying to require a provider using mongodb. I'm basing my code on the blog example from the Blog rolling tutorial on howtonode. I figured out that the require needs to be within the zappa require, like so:
When I run the app, however, I get the following error:
Where the provider-mongodb.js file starts with
Is there a better way to use mongodb providers with Zappa? Is there something I should be doing to get the above code working?
Thanks,
Ethan