Preheat oven to 350°F (175°C). Grease and flour two 9-inch round cake pans or one 9×13-inch baking pan.
In a large bowl, whisk together the flour, sugar, baking soda, cinnamon, and salt.
In another bowl, combine the grated carrots, crushed pineapple, nuts, and coconut.
In a third bowl, beat the eggs, then add the oil and vanilla, mixing well.
Add the wet ingredients to the dry ingredients and stir until just combined. Then fold in the carrot-pineapple mixture.
Pour the batter evenly into the prepared pan(s) and bake for 35-40 minutes for round pans, or 45-50 minutes for a rectangular pan. The cake is done when a toothpick inserted in the center comes out clean.
Allow the cake to cool completely in the pan(s) before frosting.
For the frosting, beat the cream cheese and butter until smooth and creamy. Gradually add the powdered sugar and vanilla, beating until fluffy. Gently fold in the well-drained crushed pineapple.
If using round pans, place one layer on a serving plate, spread with frosting, top with the second layer, and frost the top and sides. If using a rectangular pan, simply frost the top of the cake.
Sprinkle with toasted coconut if desired and serve.
Notes
For an extra tropical twist, add 1/2 cup diced mango or papaya to the batter. Store leftovers in the refrigerator for up to 5 days.