Preheat your oven to 350°F (175°C) and grease a 9x13 inch baking pan.
In a large bowl, mix the grated carrots, granulated sugar, brown sugar, and vegetable oil.
Beat in the eggs one at a time until well combined.
In another bowl, whisk together the flour, baking powder, cinnamon, nutmeg, and salt.
Gradually add the dry ingredients to the wet mixture, stirring until just combined.
Fold in the chopped walnuts if using.
Pour the batter into the prepared baking pan, spreading it evenly.
Bake for 30 minutes, or until a toothpick inserted in the center comes out clean.
Allow the bars to cool completely in the pan.
In a separate bowl, mix the cream cheese, powdered sugar, and vanilla until smooth, then spread over the cooled bars.