Meteor.loginWithPassword / Accounts.loginWithPassword is not a function

#1

I have set up a REST Api using nimble:restivus and am trying to log into my meteor server from a standalone react app.

However when I try to use either Meteor.loginWithPassword or Accounts.loginWithPassword I get the following error:

Accounts.loginWithPassword is not a function.
Meteor.loginWithPassword is not a function.

I have imported:

import { Meteor } from “meteor/meteor”;
import { Accounts } from “meteor/accounts-base”;

I have also tried JsonRoutes but the issue is the same. I have tried Node v6, v7, v8.

Any help would be appreciated.

#2

You need the accounts-password package to get Meteor.loginWithPassword.

#3

I have tried to import both, accounts-base and accounts-password but no luck.

#4

This happened to me as well. I found that Meteor.Meteor.loginWithPassword worked.

I then removed the Meteor import from my class and Meteor.loginWithPassword worked.

Somehow Meteor was already imported for the class.

#5

I just ran into this issue and worked through @greggorman s solution. When I did this I realised that the reason Meteor.Meteor.loginWithPasswords works but Meteor.loginWithPassword doesn’t is because I was importing with

import Meteor from ‘meteor/meteor’;

the trick is to use

import { Meteor } from ‘meteor/meteor’;

This works because Meteor is being deconstructed here so Meteor.Meteor is accessible as just Meteor