Preheat the oven to 350 degrees F (175 degrees C) and grease and flour a 9x13 inch baking pan or two round pans.
In a large bowl, whisk together the flour, baking powder, baking soda, cinnamon, nutmeg, and salt. Set aside.
In a separate large bowl, use a hand mixer or stand mixer to beat together the vegetable oil and sugar until light and fluffy.
Beat in the eggs one at a time, mixing well after each addition.
Stir in the grated carrots and walnuts, if using.
Gradually add the dry ingredients to the wet ingredients, mixing just until combined. Don't overmix!
Pour the batter into your prepared pan(s).
Bake the cake for 30-35 minutes (adjust based on your pan choice), or until a toothpick inserted into the center comes out clean.
Let the cake cool completely in the pan(s) before frosting.
Make the frosting: Beat together the cream cheese, butter, powdered sugar, and vanilla extract until smooth and fluffy. Spread the frosting over the cooled cake(s).
Notes
Use freshly grated carrots for the best flavor and texture.
Don't be afraid to experiment with additions! Try chopped pineapple, raisins, or coconut flakes.
Cream cheese frosting is classic, but this cake is also yummy with vanilla buttercream or a simple powdered sugar glaze.