It depends on a whole lot of factors. In a sunny place like CA with good solar incentive programs, assuming good southern to southwestern exposure, they are cash positive after about 6 years [1]. In Wisconsin, 11 years [2]. In Washington State, 15 years [3]
1. https://www.energysage.com/solar-panels/ca/#:~:text=For%20Ca....
2. https://www.energysage.com/solar-panels/wi/#:~:text=In%20Wis....
3. https://www.energysage.com/solar-panels/wa/#:~:text=In%20Was....