Preheat your oven to 350°F (175°C). Line a muffin tin with cupcake liners.
In a large mixing bowl, whisk together the flour, baking powder, baking soda, cinnamon, nutmeg, and salt.
In a separate bowl, combine the granulated sugar, brown sugar, and vegetable oil. Mix until smooth, then add the eggs one at a time, beating well after each addition.
Gradually add the dry ingredients to the wet mixture, stirring until just combined. Fold in the grated carrots, crushed pineapple, and chopped walnuts (if using).
Divide the batter evenly among the prepared cupcake liners, filling each about ⅔ full.
Bake in the preheated oven for 18-20 minutes, or until a toothpick inserted into the center comes out clean. Let the cupcakes cool in the pan for 5 minutes before transferring them to a wire rack to cool completely.
To make the cream cheese frosting, beat together the softened cream cheese and unsalted butter in a mixing bowl until creamy.
Gradually add the powdered sugar and vanilla extract, beating until smooth and fluffy.
Once the cupcakes are completely cooled, frost with the cream cheese frosting using a spatula or a piping bag.