Meteor.JS - accounts-password : TypeError: Accounts.createUser is not a function

Meteor.JS - accounts-password : TypeError: Accounts.createUser is not a function

我正在创建一个应用程序并收到以下错误:

TypeError: Accounts.createUser 不是函数

这是我的代码:

    Template.register.events({
    'submit form': function(event){
    event.preventDefault();
    var email = $('[name=email]').val();
    var password = $('[name=password]').val();
        var fname = $('[name=fname]').val();
        var lname = $('[name=lname]').val();

    Accounts.createUser({
        email: email,
        password: password,
            profile: {
            fname: fname,
            lname: lname,
            IsActive: 0
            }

    });
    Router.go('home');
    }
});

我正在使用:帐户密码包

我也在用MONGO_URL (MONGO_URL=mongodb://localhost:27017/MYDB)

我试过了:流星重置

还通过以下方式重新创建了应用:meteor create myapp

我可以通过已经创建的用户登录,以前没有任何问题,我创建了一个用户,但现在却出现了这个问题,我该怎么办?

请验证您的字段名称是否相同。 如果相同,试试这个:

funname:function(event,target){
    email=target.find(".your field class name or # field id").value;

}

这是我做错的地方:

我正在使用一个名为 Accounts 的集合,见下文:

旧代码

Accounts = new Meteor.Collection('accounts');

订阅数:

Meteor.publish('Accounts', function(){
return Accounts.find();
});

并使用助手:

Template.account_screen_account_view.helpers({

FetchAccountViewData: function () {
var editid = Router.current().params._id;
return CustomerAccounts.findOne({_id:editid});
}

});

它与以下代码冲突:

  Accounts.createUser({
    email: email,
    password: password,
        profile: {
        fname: fname,
        lname: lname,
        IsActive: 0
        }

});

新代码(已更改)

CustomerAccounts = new Meteor.Collection('customeraccounts');

Meteor.publish('CustomerAccounts', function(){
return CustomerAccounts.find();
});


Template.account_screen_account_view.helpers({

FetchAccountViewData: function () {
var editid = Router.current().params._id;
return CustomerAccounts.findOne({_id:editid});
}

});

现在问题已经解决了。有时我们会忘记研究这些事情,我很乐意分享我的经验,就像您使用 Meteor 帐户一样,然后您需要更改您自己的集合和函数的名称,因为它们可能会发生冲突并产生此类问题。