There are also machine guns and other ordinance to repel invaders. This modern penchant, from lefties, for using non-lethal means against people who are trying to shoot you with real weapons is sheer folly.
a) The law of human nature says if the prize is good enough, the pirates will find ways around any such defense. They will just get them next time.
b) This is an expensive rabbit hole to throw things down.
But there is a reason we are not removing this vermin. I’m not sure in toto what it is, but mighty nations make up their minds and destroy pirates.