First thing to do is keep calm. Knights look a fair bit more threatening than they actually are. If you refuse to be intimidated you've won half the battle. The number of shots they can put out is actually fairly limited, which is why they have a hard time dealing with horde armies.
For ranged combat, prefer higher-strength weaponry over high-AP because the Ion Shield gets in the way. You appear to be playing SM, which means your basic bolter kinda sucks against Knights as you really want to spam S5+ against the big ones (Tau get S5 standard, Necron Tesla weaponry similarly works pretty well).
In CC they don't get the Ion Shields, so additional AP is more valuable there.
Still, it's not like you don't have options, and if all else fails you can always bring a friend
Ask not the Eldar a question, for they will give you three answers; all of which are true and horrifying to know.