Preheat the oven to 350°F (175°C). Grease and flour a 9x13-inch baking dish. Set aside.
Whisk together the flour, sugar, baking powder, baking soda, salt, cinnamon, and nutmeg in a large mixing bowl.
Beat the eggs in a separate bowl and then add the vegetable oil and vanilla extract. Mix well.
Pour the wet ingredients into the dry ingredients and stir until just combined.
Fold in the grated carrots, crushed pineapple, and nuts (if using).
Transfer the batter to the prepared baking dish and spread it into a smooth, even layer.
Bake for 35-40 minutes or until a toothpick inserted into the center comes out clean. You can also gently press the center with your finger. If it springs back, the cake is done.
Allow the cake to cool completely.
Frosting
Beat the cream cheese and butter together in a mixing bowl.
Slowly add the confectioner’s sugar and vanilla extract, mixing until smooth and creamy.
Once the cake has cooled, spread the cream cheese frosting evenly over the top of the cake.