Do I have 2 versions of jQuery in my project?

I use Blaze, Meteor 2.6.

Blaze relies on an old version of jQuery, which must exist in .meteor/packages, otherwise Blaze can’t function.

I’m using jQuery via NPM. I’ve got "jquery": "^3.5.1" in package.json.

There was a change a while ago, but after looking into it a bit, it’s still unclear to me: Is the deal that Blaze uses my NPM version, or do I have 2 versions of jQuery bundling with my app?

My question is: Is there a way to make Blaze use my version of jQuery, or is there a way I can use the Blaze version?

Thank you!

I dug through the bundle visualizer but I’ve got way too many packages to sift through and find two jQuery strings. (A search feature would be nice.)

There’s this thread but it’s not clear to me: Remove old Jquery after 1.8.3 update on project that uses blaze-html-templates - #4 by coagmano

Anyone ? :slight_smile: bump bump

Do you also have jQuery in .meteor/versions? Which version is it?

Oh, well there’s a good question.

Yep, 3.0.0 in .meteor/versions and “^3.5.1” in package.json.

Duh. Thank you. I’ll use the Meteor version!

Thank you!

I have another thread on here about this. The problem is many of your npm packages will need the npm version of jQuery and thus install it. But many meteor packages also require jQuery.

Under your .meteor/packages file if you install jquery@3.0.0! with the exclamation point, this tells meteor to refer to the npm version of the package and not install another version just for your meteor packages.

I was championing for something like this for underscore and other common packages that are duplicated like this, but unfortunately to my knowledge jQuery is the only one that works like this.

1 Like

Thanks so much.

OK, so modifying .meteor/packages to say jquery@3.0.0! is all good.

I then set my NPM version of jQuery specifically to 3.0.0 as well, using meteor npm uninstall jquery && meteor npm install --save --save-exact jquery@3.0.0

I’m assuming if the NPM version is different from the meteor version, it’ll install both, so I’m just using 3.0.0. It became sad and complained when I tried to install a more recent version, as Blaze wants 3.0.0 as the maximum version, from what I understood.

That makes a lot of sense about the ‘!’ for underscore+.

Thanks for all your help!

1 Like

No, I think setting the meteor version of jQuery to 3.0.0! makes it use whatever version is installed by npm, for better or worse. I believe it “loosens” the dependency to any meteor packages and upon running, they’ll use the npm version, which should work in most cases.

I run Meteor 2.7.1 with the latest blaze and we use jQuery 3.6.0 via npm. All runs great. I can do a bundle visualizer just to double check there’s not two jQuery’s but last time I checked there was only one.

1 Like

Here is a good explanation on how the exclamation work on package versions

1 Like