In 1777, Monroe was promoted to major and assigned to the staff of Major General William Alexander, Lord Stirling. Starting in January of 1778, he was encamped with the Revolutionary Army at Valley Forge in Pennsylvania. The spot was selected by George Washington as a secure location to house the troops for the winter because it was close enough to keep tabs on the British but far enough away that a surprise attack would be unlikely.
The weather that winter wasn’t extremely cold, but mainly wet and damp, which made it hard for the soldiers to stay dry and easy for disease to spread. They received irregular supplies of food, sometimes living on “fire cake,” which was a mixture of flour and water. Around 2,500 soldiers died of disease and exposure, and Washington worried that the entire army would either starve to death or have to be dissolved. However, Monroe and the men persevered, and emerged in the spring, having been well-drilled by Prussian-born General von Steuben, to win a decisive victory at the Battle of Monmouth.
Read more about Valley Forge.