Lepozepo / cloudinary

MIT License
94 stars 42 forks source link

Cannot read property 'Cloudinary' of undefined #94

Open slevr opened 7 years ago

slevr commented 7 years ago

So: been working on this for hours, gotta be something simple I'm missing but I'm not sure where the fault may lay. This issue only happens upon deploying to Heroku as it works fine locally. So, not sure if it's a buildpack issue or something with this package. For whatever reason heroku doesn't seem to recognize the package or the way Cloudinary is being defined. I'm using Meteor 1.4.0.1 as well. Any ideas?

/app/.meteor/heroku_build/app/programs/server/node_modules/fibers/future.js:280 throw(ex); ^ TypeError: Cannot read property 'Cloudinary' of undefined at meteorInstall.imports.startup.server.cloudinary-config.js (imports/startup/server/cloudinary-config.js:5:15) at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1) at Module.require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1) at Module.Mp.import (/app/.meteor/heroku_build/app/programs/server/npm/node_modules/meteor/modules/node_modules/reify/lib/runtime.js:70:16) at meteorInstall.imports.startup.server.index.js (imports/startup/server/index.js:1:1) at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1) at Module.require (packages/modules-runtime/.npm/package/node_modules/install/install.js:82:1) at Module.Mp.import (/app/.meteor/heroku_build/app/programs/server/npm/node_modules/meteor/modules/node_modules/reify/lib/runtime.js:70:16) at meteorInstall.server.main.js (server/main.js:1:8) at fileEvaluate (packages/modules-runtime/.npm/package/node_modules/install/install.js:153:1)

Here is my server code:

import { Meteor } from 'meteor/meteor';

Cloudinary.config({ cloud_name: Meteor.settings.public.Cloudinary.CLOUD_NAME, api_key: Meteor.settings.private.Cloudinary.API_KEY, api_secret: Meteor.settings.private.Cloudinary.API_SECRET, });

I also added import { Cloudinary } from 'meteor/lepozepo:cloudinary'; just to see if a specific import would do anything but no joy

Lepozepo commented 7 years ago

Damn, I'm not sure really, I've never worked with heroku. Does it work locally?

slevr commented 7 years ago

Yeah, I'm not sure either and was hoping someone may have seen this before so started here. It is working locally, though. Between using the latest meteor 1.4, heroku and cloudinary, all being fairly new to me, there's no telling at this point. I'm leaning toward a heroku deployment issue at this point, however.

jamesmacfie commented 7 years ago

I had this recently (locally, not on deploy as I haven't tried that yet) and my issue was that I had to specify a --settings flag. You could try being specific with that in your run step and see if that changes anything?

Lepozepo commented 7 years ago

That's very strange, lol, there's definitely nothing in the package requiring --settings. Are you importing the package? I haven't tried that but I'm sure that importing it would mess things up (I haven't gotten around to resolving that yet)

slevr commented 7 years ago

@jamesmacfie - unfortunately, I've used the --settings flag all along and it does run locally just fine for me. I only see this error when trying to run in heroku. I actually haven't revisited this however in a couple weeks due to other priorities so am just assuming the issue remains. @Lepozepo - I'm not importing it ( though I did try to once I saw issues just to see plus other things ) - just using the atmosphere package. Hopefully, I can look into it more this week - I'm still not so sure it's a cloudinary issue.

mervynteo commented 6 years ago

This issue came up again when i tried to fit it all into Meteor's new directory structure. I have a settings file with all the keys and also says

Uncaught TypeError: Cannot read property 'cloudinary' of undefined

in reference to this code. I have the keys in a settings.json file

Cloudinary.config({
   cloud_name  : Meteor.settings.private.cloudinary.cloud_name,
   api_key     : Meteor.settings.private.cloudinary.api_key,
   api_secret  : Meteor.settings.private.cloudinary.api_secret
});

The error appears only for the browser , not on the server.

lmachens commented 6 years ago

@mervynteo Meteor.settings.private are only available on the server. You should move the cloud_name to Meteor.settings.public and initiate cloudinary on the client like:

$.cloudinary.config({
    cloud_name: Meteor.settings.public.cloudinary.cloud_name
})

Cloudinary.config is for server side only.