sticky-kit icon indicating copy to clipboard operation
sticky-kit copied to clipboard

Cannot read property 'jQuery' of undefined

Open zomars opened this issue 8 years ago • 15 comments

I'm getting this error when the file is being concatenated in a minified file and it's pointing to this line.

zomars avatar Oct 27 '16 18:10 zomars

Hi, I delete temporary this from string this.jQuery and left this:

$ = window.jQuery;

dmitrylebedev avatar Oct 28 '16 07:10 dmitrylebedev

Tha's what I did too.

zomars avatar Oct 28 '16 15:10 zomars

Is this something about your setup that would have jQuery not be available in the name jQuery?

leafo avatar Nov 01 '16 03:11 leafo

jQuery is available, but not under the "this" namespace. If it helps to know, I'm using the jquery dist file from bower. And the only thing I'm doing is concatenating those files in the correct order.

zomars avatar Nov 01 '16 13:11 zomars

this should default to window, is the library getting wrapped in something that's changing that?

leafo avatar Nov 02 '16 18:11 leafo

Yeah can confirm that this.jQuery is causing this module to be unusable with a modern build system ( browserify or webpack ) Can it just be removed ?

tim-field avatar Nov 03 '16 00:11 tim-field

It's not getting wrapped and it's the first file being called.

zomars avatar Nov 03 '16 16:11 zomars

@leafo could you please update npm package for v1.3 ?

rebusweb avatar Dec 01 '16 13:12 rebusweb

Am I missing something or is this still a thing? I installed the lib via npm (1.1.3 on npm), but still have the this.jQuery in it. I see that the current version here on GitHub has it fixed, but still get the old code and error from npm.

maurobringolf avatar Oct 11 '17 07:10 maurobringolf

@maurobringolf Don't use npm package, use npm and github link github:leafo/sticky-kit

rebusweb avatar Oct 11 '17 07:10 rebusweb

@rebusweb Will this install master branch or latest release on github? Thanks for the hint! But this is a workaround, right?

maurobringolf avatar Oct 11 '17 07:10 maurobringolf

@maurobringolf it's master, but you can also use github:username/package#commit convention. yes, it's kind of a workaround, but using github links in npm is a standard functionality.

rebusweb avatar Oct 11 '17 07:10 rebusweb

Awesome, thank you very much!

maurobringolf avatar Oct 11 '17 07:10 maurobringolf

How do you guys manage to build it? I get another error: https://github.com/leafo/sticky-kit/issues/248

@rebusweb How do you include it? Do you use Browserify?

OnkelTem avatar Oct 17 '17 10:10 OnkelTem

@OnkelTem nope.

rebusweb avatar Oct 17 '17 14:10 rebusweb