Preheat your oven to 350°F (175°C). Grease and flour two 9-inch round cake pans or a 9×13-inch baking dish.
In a medium bowl, whisk together the flour, baking soda, salt, cinnamon, and nutmeg.
In a large mixing bowl, combine the oil, granulated sugar, and brown sugar. Beat them together until well combined.
Add the eggs, one at a time, mixing well after each addition.
Gradually add the dry ingredients to the wet ingredients, mixing on low speed until just combined.
Gently fold in the crushed pineapple, grated carrots, and if using, the nuts and coconut.
Divide the batter evenly between your prepared pans. Bake for 30-35 minutes (or 40-45 minutes for a 9×13 pan), or until a toothpick inserted into the center comes out clean.
Let the cakes cool in the pans for 10 minutes, then turn them out onto a wire rack to cool completely.
While the cakes cool, beat the softened cream cheese and butter together until smooth and creamy.
Gradually add the powdered sugar, vanilla, and salt, beating until the frosting is fluffy.
Once the cakes are completely cool, frost the top of one layer, place the second layer on top, and frost the entire cake.
Notes
This Perfect Carrot Cake recipe is incredibly moist, perfectly spiced, and topped with a luxuriously creamy frosting. It’s a simple, family-friendly dessert that’s great for make-ahead occasions.