Preheat the oven to 350°F (175°C) and grease a 9x13 inch baking pan.
Whisk together the flour, sugar, baking powder, baking soda, cinnamon, and salt in a mixing bowl.
Mix the eggs and vegetable oil in another bowl until well combined.
Combine the wet ingredients with the dry ingredients by stirring until just merged.
Fold in the grated carrots and walnuts (if using).
Pour the batter into the prepared baking pan and spread it evenly.
Bake for 25-30 minutes or until a toothpick inserted in the center comes out clean.
Cool completely before frosting.
Beat the softened cream cheese and butter together in a mixing bowl until smooth.
Gradually add the powdered sugar and vanilla extract, mixing until well combined and fluffy.
Spread the cream cheese frosting over the cooled carrot cake bars evenly.
Cut into squares and serve!