SBD
SBD

Reputation: 446

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
            }

        });

    },

  });
}

Upvotes: 4

Views: 3908

Answers (2)

TDmoneybanks
TDmoneybanks

Reputation: 518

You most likely did not add anything besides accounts-base. This will not give you the functionality of the baked-in accounts package. You need to add accounts-base and then one of the solutions for verifying users. There are plenty of options some of the most popular being: accounts-password as said above along with accounts-facebook, accounts-twitter, and several third party packages like accounts-linkedin found here https://atmospherejs.com/yefim/accounts-linkedin

Upvotes: 0

David Weldon
David Weldon

Reputation: 64312

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

$ meteor add accounts-password

Upvotes: 8

Related Questions