Preheat the oven to 350°F (175°C). Line a muffin tin with cupcake liners.
In a medium bowl, whisk together the flour, baking powder, baking soda, cinnamon, nutmeg, and salt. Set aside.
In a large mixing bowl, combine the granulated sugar, brown sugar, and vegetable oil. Mix until well blended.
Add the eggs one at a time, mixing well after each addition, and then add the vanilla extract.
Gradually mix in the dry ingredients until just combined. Do not overmix.
Fold in the grated carrots, crushed pineapple, and chopped nuts (if using) with a rubber spatula.
Divide the batter evenly among the prepared cupcake liners, filling each about two-thirds full.
Bake in the preheated oven for about 20 minutes, or until a toothpick inserted into the center comes out clean.
Allow the cupcakes to cool in the pan for 5 minutes, then transfer them to a wire rack to cool completely.
For the cream cheese frosting, beat the softened cream cheese and butter together in a mixing bowl until smooth.
Gradually add the powdered sugar and vanilla extract, mixing until velvety and well combined.
Once the cupcakes are completely cooled, frost them generously with the cream cheese frosting using a spatula or piping bag.