punddalinni
punddalinni

Reputation: 21

Uncaught ReferenceError: Meteor is not defined

I'm following a tutorial to create a Meteor app and I've been having the same error regarding different things in the developer console.

> Meteor.users.find().count();
VM2034:1 Uncaught ReferenceError: Meteor is not defined(…)(anonymous function) @ VM2034:1

> Session.set('pageTitle', 'A different title');
VM2035:1 Uncaught ReferenceError: Session is not defined(…)

From researching the problem, the 2 solutions that come up are: (1) doing

meteor add session

which I have done; (2) updating the Meteor version but I am running Meteor 1.3.3. Neither works.

EDIT: After doing meteor update, the Meteor error disappeared once but came back the second time I tried a command based on Meteor.

Any idea on how to solve this?

Upvotes: 0

Views: 2442

Answers (1)

Ilanus
Ilanus

Reputation: 6928

If you are trying to set the session outside the client folder you will get this error. Which is why you must do:

if(Meteor.isClient) {
 Session.set('pageTitle', 'A different title');
}

Then you can check it worked simple write in console:

Session.get('pageTitle')

Will output: "A different title"

Good luck!

Upvotes: 1

Related Questions