By the Third Age, gunpowder iswas obviously invented, but it iswas very rarely used. In late medieval and early modern Europe (and subsequently on the whole planet) it completely changed warfare.
As Middle Earth is a very low-magic setting, gunpowder would not be made obsolete by magic, as magic hardly exists at all.
We don't see any cannon artillery, or tercios which would mop up the floor with a similarly sized army from Middle Earth (maybe except the Elves whose archery would probably still be superior to muskets).