Prepare the oven and pan: Preheat the oven to 350°F (175°C). Grease a 9×13-inch baking pan and line the bottom with parchment paper.
Drain the pineapple: Place the crushed pineapple in a fine-mesh strainer and gently press out excess juice. Keep the pineapple moist rather than squeezing it completely dry.
Prepare the dry ingredients: Whisk together the flour, baking soda, baking powder, cinnamon, ginger, nutmeg, and salt in a medium bowl.
Mix the wet ingredients: In a large bowl, whisk the granulated sugar, brown sugar, vegetable oil, eggs, and vanilla until smooth.
Add the carrots and pineapple: Stir the finely grated carrots and drained crushed pineapple into the wet mixture. Fold in the coconut and chopped nuts if using.
Combine the batter: Add the dry ingredients to the wet mixture and gently fold with a spatula just until the flour disappears. Do not overmix.
Bake: Spread the batter evenly in the prepared pan and bake for 35–40 minutes, or until the center is set and a toothpick inserted into the middle comes out with a few moist crumbs.
Cool: Let the cake cool in the pan for about 15 minutes, then transfer it to a cooling rack and allow it to cool completely.
Make the glaze: Beat the softened cream cheese and butter until smooth. Gradually mix in the powdered sugar, then add vanilla and a pinch of salt.
Adjust the glaze: Add milk a little at a time until the cream cheese mixture reaches a smooth, spreadable or drizzle-friendly consistency.
Finish the cake: Spread or drizzle the cream cheese glaze over the completely cooled cake. Add toasted coconut or chopped nuts on top if desired.
Serve: Slice and serve once the glaze has set slightly. Refrigerate leftovers in a covered container.