If you want to use a nut, but find there is not enough room for it, here is an easy bodge that I have used a few times: -
Just take a nut one size below, drill it out and tap it to the size you wanted. This is very easy to do because the outer thread size of the smaller nut is about the same as the tap drill size of the bigger one, so you only really have to drill the thread away.
The nut on the left is a proper M5 nut, the one on the right is an M4 nut tapped to M5. Obviously it will have a lower maximum load but it can get you out of a hole.