eric
eric

Reputation: 1

Meteor is crashing with jQuery

I am having an issue with Meteor and Jquery. I have add in both underscore.js and jquery yet I still get the follow error when I try and run the code. The server fails before it ever starts.

Any help would be appreciated.

Here is a copy of the output window. I know I am missing something really simple. I can get other meteor apps to run.

=> Meteor server running on: localhost:3000/

.meteor\local\build\server\server.js:34
5
  }).run();
     ^
ReferenceError: jQuery is not defined
    at app/lib/jquery-ui.custom.min.js:4:4148
    at \.meteor\local\build\server\serve
r.js:306:12
    at Array.forEach (native)
    at Function._.each._.forEach (C:\Users\rodgerse\node_modules\underscore\unde
rscore.js:79:11)
    at run (\.meteor\local\build\server\
server.js:239:7)
=> Exited with code: 1
=> Meteor server restarted

\.meteor\local\build\server\server.js:34
5
  }).run();
     ^
ReferenceError: jQuery is not defined
    at app/lib/jquery-ui.custom.min.js:4:4148
    at \.meteor\local\build\server\serve
r.js:306:12
    at Array.forEach (native)
    at Function._.each._.forEach (C:\Users\rodgerse\node_modules\underscore\unde
rscore.js:79:11)
    at run (\.meteor\local\build\server\
server.js:239:7)
=> Exited with code: 1
=> Meteor server restarted

\.meteor\local\build\server\server.js:34
5
  }).run();
     ^
ReferenceError: jQuery is not defined
    at app/lib/jquery-ui.custom.min.js:4:4148
    at \.meteor\local\build\server\serve
r.js:306:12
    at Array.forEach (native)
    at Function._.each._.forEach (C:\Users\rodgerse\node_modules\underscore\unde
rscore.js:79:11)
    at run (\.meteor\local\build\server\
server.js:239:7)
=> Exited with code: 1
=> Your application is crashing. Waiting for file change.

Upvotes: 0

Views: 361

Answers (2)

Daniel Bernhard
Daniel Bernhard

Reputation: 382

To iterate through arrays on the server, you should use underscore's ._each method. It comes with Meteor so there are no packages to install or anything like that.

So, instead of:

$.each(someArray, function (index, element) {
   //Some awesome logic
})

You can do:

_.each(someArray, function (element, index, list) {
    //Some awesome logic.
});

Check this out for more info.

Upvotes: 3

mquandalle
mquandalle

Reputation: 2598

jQuery is only available on the client - not the server [1]. So, because it has a dependency on jQuery, your file will only work on the client. You should put it in the client directory:

app/client/lib/jquery-ui.custom.min.js

Upvotes: 1

Related Questions