Preheat the oven to 350°F. Grease a 9x13-inch cake pan with cooking spray and dust with flour.
In a large bowl, whisk together the flour, grated carrots, white sugar, brown sugar, baking soda, cinnamon and salt.
In a separate medium bowl, whisk together the eggs, melted butter, sour cream, vanilla extract and crushed pineapple with juice. Add the wet ingredients to the dry and mix just until combined. Stir in the chopped pecans (optional).
Pour the batter into the prepared cake pan then bake the cake until a toothpick inserted comes out clean, 35 to 40 minutes. Allow the cake to cool completely while you prepare the frosting and decorations.