Asking user to login in the middle of a purchase in a website used years ago

If a visitor tries to make a purchase on an website from which they made a purchase maybe a few years ago, during checkout it might happen that the user does not remember he has an account and as I noticed the flow turns weird and bad for the visitor like this:

The user goes to checkout and is prompted to either login or checkout as guest or sign up.

Given that the user might not remember he even has an account let`s suppose he will try to checkout as guest.

Once he enters his email he will be prompted with an error "An account exists with this email address . Please login!"

Now the visitor tries to login but obviously he will not know the password and there frustration will hit and breaking a vital flow ( It might even stop the user from ordering by being frustrated, or getting his account locked by trying different passwords ). Try to reset passwords, go to e-mail, set a new password etc...

How would you go about to fix this ?

I have not seen this issue being tackled by anyone but maybe there are websites that solved this somehow.