Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Meteor: Uncaught ReferenceError: Accounts is not defined

I'm following a tutorial on learning MeteorJS, however I get this strange error when calling the 'Accounts' object method 'createUser':

Meteor:  Uncaught ReferenceError: Accounts is not defined

I looked up the docs, and Meteor offers a whole account system on installing Meteor in your project. (https://www.meteor.com/accounts). What is the cause of this error? I can't find an answer to this.

My code:

if (Meteor.isClient) {



 Template.login.creatingAccount = function()
  {
    return Session.get('creatingAccount');

  }, 



Template.login.events({


    'click #loginform': function()
    {
        Session.set('creatingAccount', false);
    }, 
    'click #accountform': function()
    {
        Session.set('creatingAccount', true);
    },
    'click #createAccount': function(e,t)
    {
        //make sure to show the login form
        Session.set('creatingAccount', false);
        Accounts.createUser({ 

            username: t.find('#username').value, 
            password: t.find('#password').value, 
            email: t.find('#email').value, 
            profile: {
                name: t.find("#username").value, 
                email: t.find("#email").value
            }

        });

    },

  });
}
like image 820
SBD Avatar asked Feb 11 '23 23:02

SBD


1 Answers

It's likely that one of the accounts packages was not added to your project. Try:

$ meteor add accounts-password
like image 87
David Weldon Avatar answered Feb 13 '23 11:02

David Weldon