It would be a big deterrent but a well equiped modern army would crush local militia particularly if they cared not about the indigenous people but only the land. General Sherman style warfare would effectively end gorrilla warfare. Comparing Iraq or afganistan is not aplicable. If the US had not cared at all about the iraqi people there wouldn't have be any real insurgency because the Iraqis would have all been dead.
The iraqis don't have anything close to the funding of the US military. And, if the US military just started slaughtering people, you can bet on every last Iraqi grabbing a gun and going after the invaders where they sleep. The level of resistance thus far doesn't even begin to compare. Heck, look at the Afghans vs the USSR -- just about the most powerful land military on the globe at the time, while the Afghans were a bunch of dirt poor tribesmen with a few SAMs and IEDs.
If you put a centrally controlled army, vs an equally funded and equipped collection of independent militias, the army would be obliterated. It wouldn't even be close.
The idea of independent militias, which join together in time of general attack, has several advantages -- among them:
1. There isn't the huge burden of maintaining a full time fighting force
2. There isn't the "when you have a hammer everything's a nail" problem.
3. No military industrial complex lobbying for war.
4. No war by the command of one individual, or body -- and your own skin's on the line. This encourages caution.
5. No central command and control to take out -- or take over.
6. Independent militias allow for independent creativity -- an approach slow to adjust central armies can't contend with.
7. Intelligence gathering by the enemy is nearly impossible.
8. Increases community cohesion in peacetime, as average folks go out training or shooting together on a regular basis.
9. This arrangement makes the fighting force almost impossible to use an an offensive weapon, or as a tool of tyranny.
10. Troops are beholden to their communities, not to a central government.
I went through the numbers one time. For a small fraction of the 350 billion americans spent on charity last year, you could buy an AK47 for one in every three adults, RPG-7s for one in every ten, and more than a million stinger SAMs. Plus, you've got the fact that in a free economy people would be far more wealthy, they'd be spending money every year on defense, and there's already more guns than people in the US. Then, you've got the tactical advantages created by independent militias, which are capable of rapid, creative action, and are nearly impervious to intelligence efforts. Oh, and these militias include 50-100 million people.
Invading under these circumstances would be absolute suicide.