Prepare the Cupcakes:
Preheat your oven to 350°F (175°C). Line a muffin tin with cupcake liners.
In a medium bowl, whisk together the flour, baking powder, baking soda, salt, cinnamon, and nutmeg.
In a large bowl, beat together the eggs, granulated sugar, vegetable oil, and vanilla extract until smooth and well combined.
Gradually add the dry ingredients to the wet ingredients, mixing until just combined.
Stir in the grated carrots and, if using, the walnuts or pecans.
Divide the batter evenly among the cupcake liners, filling each about 2/3 full.
Bake for 18-22 minutes, or until a toothpick inserted into the center of a cupcake comes out clean.
Let the cupcakes cool in the tin for 5 minutes, then transfer them to a wire rack to cool completely.
Prepare the Cream Cheese Frosting:
Beat the softened cream cheese and butter together in a large bowl until smooth and creamy.
Gradually add the powdered sugar, 1 cup at a time, beating well after each addition.
Add the vanilla extract and a pinch of salt, and beat until the frosting is fluffy and smooth.
If the frosting is too thick, add a little milk to reach your desired consistency.
Frost the Cupcakes:
Once the cupcakes are completely cool, frost them with the cream cheese frosting using a piping bag or a spatula. You can garnish with additional chopped nuts or even a small grated carrot for decoration.