bcrypt.compare always returns false when comparing passwords

For some reason bcrypt.compare stopped working and doMatch always returns false. I’m able to create new users with hashed password but then cannot log in for the aforementioned reason. My login controller is:

  const postLoginController = async (req, res) => {
  const email = req.body.email;
  const password = req.body.password;
  try {
    User.findOne({ email: email }).then((user) => {
      console.log('password, user.password', password, user.password);
      bcrypt.compare(password, user.password).then((doMatch) => {
        console.log('doMatch', doMatch);
        //Comparing the password the user entered with the password stored in the db
        if (doMatch) {
          console.log('passwords match');
          req.session.isLoggedIn = true;
          req.session.user = user;
          req.session.save();
          res.status(200).json({ isLoggedIn: true, message: 'Logged in!' });
        } else {
          res
            .status(401)
            .json({ isLoggedIn: false, message: 'Invalid credentials. Please try again.' });
        }
      });
    });
  } catch (err) {
    res.status(400).json({ error: 'Failed to login.' });
  }
};

The console.log returns both the string and the hashed passwords:

password, user.password 123456 $2a$12$9YqCOmycoiLJ8uf7HfL4HebR2hHrJ7b2e6YspG7cP8.6UeAbapHEm

However, as I mentioned, comparing them results in doMatch always being false. Any idea why this is happening? It was working previously. I reinstalled bcryptjs, which is at version 2.4.3 currently, but it didn’t help.