mc9
mc9

Reputation: 6349

Meteor: jQuery is not defined

I am having a problem with using jQuery in my Meteor app. It is undefined.

When I look inside .meteor/versions, I can clearly see:

[email protected]_2

But when I type $ or jQuery in my Chrome console, I get undefined. Also, I cannot use external packages that use any jQuery; I get undefined is not a function exception.

Manually adding jQuery package by meteor add jquery did not solve the issue.

Any idea why this happens?

Upvotes: 0

Views: 1856

Answers (1)

halbgut
halbgut

Reputation: 2386

jQuery is inside the meteor core and defined as a dependency inside meteor-platform. So I never declare it as a a dependency. Meteor relies heavily on it, so it's unlikely to ever be removed. Unlike underscore, which they stated they will remove in a future release. Meteor always aliases $. So that should work. It can't be an issue with that specific version. I'm running the same without any issues. Here are some things you could try to debug:

  • Create a new project and check if JQ works
  • Check if an installed package is causing the problem (by removing them one by one)

Packages get loaded before your code, so that can't be the problem.

Upvotes: 2

Related Questions