Start by preheating your oven to 350°F (175°C) and greasing a 9×13 inch baking pan. This helps the cake bake evenly and ensures it releases easily after baking without sticking to the sides or bottom.
In a medium bowl, whisk together the flour, baking powder, baking soda, cinnamon, and salt. Mixing the dry ingredients first ensures everything is evenly distributed, so the cake rises properly and has a balanced flavor in every bite.
In a large mixing bowl, beat together the sugar, eggs, vegetable oil, and vanilla extract until the mixture becomes smooth and slightly thick. This step builds the base of your cake and helps create a soft, moist texture.
Gradually add the dry ingredients into the wet mixture and mix just until everything is combined. Be careful not to overmix, as this can make the cake dense instead of light and fluffy.
Gently fold in the grated carrots, well-drained crushed pineapple, and walnuts (if using). The batter will look thick and textured, which is exactly what you want for a rich, moist cake.
Pour the batter evenly into your prepared pan and spread it out gently so it bakes evenly. Bake for 35–40 minutes, or until a toothpick inserted in the center comes out clean.
Once baked, let the cake cool completely in the pan. This step is very important because warm cake will melt the frosting and ruin its texture.
To make the frosting, beat together the cream cheese, butter, powdered sugar, and vanilla extract until smooth, creamy, and fluffy with no lumps.
Finally, spread the frosting evenly over the cooled cake and decorate with extra pineapple or shredded carrots if desired. Slice and serve once set.