I had the same issue and, for me it was a weak VMO - vastus medialis oblique, or something like that. A pear shaped quad on the inner side of your thigh. Being weaker than other quads it allowed the knee cap to be pulled off center = pain. Patella tracking error. Simple but persistent exercises and changing how I climb stairs has "gone'd it away". Maybe read up on that via numerous websites.
I also ensured that that my saddle height was correct. I don't use clipless pedals. Outmoded toe clips and straps so my feet can move. I make sure my feet point straight ahead, not heels in.