If it is an ant such as a black ant, consider using mosquito-repellent incense.
Not only ants, but also blackfly, spiders and scale insects can repel insects by lighting mosquito-repellent incense near meaty places.
In addition, if it is because of improper fertilization that ants increase, such as washing rice with raw eggs and fermenting carrots with water, which is easy to attract mosquitoes and even rats, then we should stop using folk fertilizers and use normal succulent fertilizers, such as Oulu A2 slow-release fertilizer.
Finally, from personal experience, 99% of all kinds of pests, including but not limited to ants, can be prevented by prepared granular soil (adding pesticides) and screened peat soil. Just can't stop spiders from being annoying.