Preheat oven to 350 degrees. Line one (12-count) muffin tin with cupcake liners. Set aside.
Beat the sugar, butter, and vanilla together in the bowl of an electric mixer fitted with a paddle attachment. Add the eggs, 1 at a time. In another bowl, sift together the flour, cinnamon, baking soda, and salt. With the mixer on slow speed, add ½ of the dry ingredients. Add the grated carrots and walnuts (if using) to the remaining flour, mix well, and add to the batter. Mix until just combined.
Scoop batter into prepared cupcake liners and bake 18-20 minutes or until a toothpick comes out clean.
For the frosting, beat the softened cream cheese and powdered sugar in a medium bowl. (To quickly soften the cream cheese, I microwave for 20 seconds in a glass bowl). Stir cream cheese and sugar until smooth. (If you would like a more runny frosting, add 1 tbsp of milk and stir).
When the cupcakes are cool, frost them and serve!