Nanites are actually fairly simple to counter, you just need to cook them. Admittedly exposing explosives to high temperatures might be a bad idea.At some point in the past someone released nanites that target and neutralize any explosive compound powerful enough to make an effective gun. This means you also don't get mines or bombs.
Depending on what you want for the rest of the setting, the technical knowledge to make such nanites could've been lost. Maybe there was a Great War (during which those nanites were produced?) that set culture and technology back to the point where nobody knows how to reproduce the weapons with which it was fought - and people are highly discouraged from trying.