EddyVerbruggen / SocialSharing-PhoneGap-Plugin

👨‍❤️‍💋‍👨 Cordova plugin to share text, a file (image/PDF/..), or a URL (or all three) via the native sharing widget
MIT License
1.78k stars 906 forks source link

Require is not defined #268

Closed jdschuitemaker closed 9 years ago

jdschuitemaker commented 9 years ago

When I debug my app that uses the SocialSharing plugin I see a message saying: Uncaught ReferenceError: require is not defined

Is this expected and if so, what action should I take? I Googled for require and it seems that this has to do with node.js.

Thank you in advance!

EddyVerbruggen commented 9 years ago

Hi, has cordova.js been correctly loaded before the plugin is used?

jdschuitemaker commented 9 years ago

Hi Eddy,

Yes, I have: [image: Inline image 1]

And this is what I see in GapDebug (scroll to left to see whole picture): [image: Inline image 2]

Thank you!

Met vriendelijke groeten, Warm regards,

Jan-Dirk Schuitemaker

On Tue, Dec 23, 2014 at 12:57 PM, Eddy Verbruggen notifications@github.com wrote:

Hi, has cordova.js been correctly loaded before the plugin is used?

Reply to this email directly or view it on GitHub https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/issues/268#issuecomment-67944360 .

EddyVerbruggen commented 9 years ago

The images don't show up. Have you tested in on a real device? If that doesn't work, feel free to send me your entire codebase. Strip out anything you like of course, as long as the problem can be reproduced.

jdschuitemaker commented 9 years ago

Thanks for you support. Before sending everything to you I have one question. I noticed that the error appears before deviceready event. Could that cause the problem?

If it's okay, I can just share an APK with you. Can you share email address?

Met vriendelijke groeten, Warm regards,

Jan-Dirk Schuitemaker

On Tue, Dec 23, 2014 at 2:29 PM, Eddy Verbruggen notifications@github.com wrote:

The images don't show up. Have you tested in on a real device? If that doesn't work, feel free to send me your entire codebase. Strip out anything you like of course, as long as the problem can be reproduced.

Reply to this email directly or view it on GitHub https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/issues/268#issuecomment-67950675 .

EddyVerbruggen commented 9 years ago

Hi Jan-Dirk, that is definitely a problem; Cordova plugins can't be used before deviceready has fired.

As long as I can extract the www folder from your APK then that's ok. Email: eddyverbruggen at gmail dot com

KhaledElAnsari commented 9 years ago

Did you guys found a solution for this problem? because I'm facing it now!

jdschuitemaker commented 9 years ago

If I recall well, my issue was that I referenced socialsharing.js in my index.html file. That is not required for this plug-in. Could it be that you are experiencing the same?

Met vriendelijke groeten, Warm regards,

Jan-Dirk Schuitemaker

On Mon, Feb 16, 2015 at 4:49 PM, KhaledElAnsari notifications@github.com wrote:

Did you guys found a solution for this problem? because I'm facing it now!

Reply to this email directly or view it on GitHub https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/issues/268#issuecomment-74528283 .

KhaledElAnsari commented 9 years ago

My problem was with the Cordova file src , It was inside a folder called JS so the src was "src=JS/cordova.js" but I put it back in the main folder (src = "cordova.js") and it work so the other functions ... thanks for your help man :)

somnathsonawne commented 8 years ago

Thanks @KhaledElAnsari . Your reply (moving cordova.js back to the root ) solved my issue also.

amitpatil321 commented 8 years ago

@EddyVerbruggen Now i am facing the same issue, getting the same error. I checked solution provided by @KhaledElAnsari and my cordova.js file is in right place. I created fresh app and it worked well with it, Its just giving me "require" error with my existing app. I am listing list of plugins i am using com.ionic.keyboard 1.0.4 "Keyboard" cordova-plugin-console 1.0.1 "Console" cordova-plugin-device 1.0.1 "Device" cordova-plugin-splashscreen 2.1.0 "Splashscreen" cordova-plugin-statusbar 2.0.0-dev "StatusBar" cordova-plugin-whitelist 1.0.0 "Whitelist" cordova-plugin-x-socialsharing 5.0.8-dev "SocialSharing" org.apache.cordova.network-information 0.2.15 "Network Information"

I am also using jquery, can that also cause problem ?

amitpatil321 commented 8 years ago

Ok, Got it resolved. Dont worry about this error, I am still getting this error but social sharing plugin is working fine.