A nuclear deterrent is a more effective deterrent (but not a guarantee).
That being said conventional forces can be a effective deterrent as well. Look at Switzerland hasn’t been invaded in centuries despite being surrounded by countries that at various points in time wanted to.
Sometimes it isn’t about being able to fully defeat a invasion, it is about making the cost to invade much greater than the benefit. Look at Iran, they are losing the conventional fight, but they are making the costs much greater than the benefits.