Preheat your oven to 350°F (175°C). Grease and flour two 9-inch round cake pans.
In a large mixing bowl, whisk together the flour, sugar, baking powder, baking soda, cinnamon, and salt until well combined.
In another bowl, mix the vegetable oil and eggs until well blended. Gradually add the wet mixture to the dry ingredients, stirring until just combined.
Fold in the grated carrots, crushed pineapple, shredded coconut, and nuts (if using) until evenly distributed throughout the batter.
Divide the batter evenly between the prepared cake pans. Bake in the preheated oven for 25-30 minutes, or until a toothpick inserted into the center comes out clean. Allow the cakes to cool in the pans for about 10 minutes before transferring them to a wire rack to cool completely.
In a mixing bowl, beat the softened cream cheese and butter together until smooth and creamy. Gradually add the powdered sugar and vanilla extract, mixing until well combined. If the frosting is too thick, add milk, one tablespoon at a time, until you reach your desired consistency.
Once the cakes are completely cooled, place one layer on a serving plate. Spread a generous amount of cream cheese frosting on top. Place the second layer on top and frost the top and sides of the cake with the remaining cream cheese frosting.
