As long as you would drive enough so that difference can offset the fabrication of the EV. Most people will hit this number in less than five years.
https://www.reuters.com/business/autos-transportation/when-do-electric-vehicles-become-cleaner-than-gasoline-cars-2021-06-29/
We drive about 350km a year on a high-coal grid, so we won't drive enough for a new EV to be better for the environment than getting a used car that was headed for disposal.
I know people who drive more per day than my household drives per year, so I know that we are going to be a fairly rare case.