Preheat the oven to 350°F (175°C) and line a 9x13-inch baking pan with parchment paper.
In a large bowl, whisk together flour, baking soda, cinnamon, nutmeg, and salt.
In another bowl, mix granulated sugar, brown sugar, oil, eggs, and vanilla until smooth.
Gradually add the dry ingredients to the wet ingredients and stir just until combined.
Fold in grated carrots and nuts, if using.
Spread the batter evenly into the prepared pan.
Bake for 28–32 minutes, or until a toothpick inserted in the center comes out clean.
Let the bars cool completely in the pan.
For the frosting, beat cream cheese and butter until smooth, then mix in powdered sugar and vanilla.
Spread frosting evenly over the cooled bars, slice, and serve.