01 - Preheat oven to 350°F. Grease and flour two 8-inch round cake pans or one 9x13-inch rectangular pan, lining the bottoms with parchment paper if desired.
02 - In a medium bowl, whisk together the all-purpose flour, baking powder, baking soda, ground cinnamon, ground nutmeg, and salt until evenly distributed.
03 - In a large bowl, beat the eggs, granulated sugar, and packed light brown sugar until smooth and no lumps remain. Pour in the vegetable oil and vanilla extract, mixing thoroughly to combine.
04 - Gradually add the dry ingredient mixture to the wet ingredients, folding gently until just combined. Be careful not to overmix.
05 - Gently fold in the grated carrots. If using, fold in the chopped walnuts or pecans and the well-drained crushed pineapple until evenly distributed throughout the batter.
06 - Pour the batter into the prepared pan(s) and smooth the top with a spatula. Bake for 35 to 40 minutes, or until a toothpick inserted into the center comes out clean.
07 - Allow the cake to cool completely in the pan(s) on a wire rack before frosting. For layer cakes, turn out each layer onto the rack to cool fully.
08 - In a mixing bowl, beat the softened cream cheese and unsalted butter together using a hand or stand mixer until light and fluffy. Gradually add the sifted powdered sugar, vanilla extract, and a pinch of salt, beating until smooth and creamy.
09 - Spread the frosting evenly over the cooled cake. For a layered cake, place the first layer on a serving plate, spread frosting across the top, stack the second layer, then frost the top and sides evenly.