Answer :

Well, this question cannot really be answered generally. It's a matter of judgement, and it's best judged for particular cases. The consideration of this depends on two factors:

what are the probable costs (in terms of human life, and the quality of human life) of the invasion? - it's important not to diminish these factors, as the assessments of casualties often tend to  be lower than the actual numbers

how high is the risk of the alternative. Do we have a good, unbiased reason to believe that a spread of nuclear weapons (unchecked spread, or spread that gives reasons to worry. US has a lot of nuclear weapons, but since it's not planning to use them on other country, it wouldn't be justified to attach the US) will happen? what kind of conflict are we risking?

in any case, this is not an easy question, and perhaps there will never be a good answer for it.