Preheat your oven to 350°F (175°C) and line a muffin tin with cupcake liners.
In a large mixing bowl, whisk together the flour, granulated sugar, brown sugar, baking powder, baking soda, salt, cinnamon, and nutmeg until well combined.
In another bowl, beat together the vegetable oil and eggs until smooth. Add the grated carrots and crushed pineapple, mixing until just combined.
Gradually add the wet ingredients to the dry ingredients, stirring gently with a rubber spatula until no dry flour remains. If using, fold in the chopped walnuts or pecans.
Evenly distribute the batter into the prepared muffin tin, filling each liner about ⅔ full.
Bake in the preheated oven for 20 minutes, or until a toothpick inserted into the center comes out clean. Allow the cupcakes to cool in the tin for 5 minutes before transferring them to a cooling rack to cool completely.
For the frosting, in a mixing bowl, beat together the softened cream cheese and butter until creamy.
Gradually add the powdered sugar and vanilla extract, mixing until smooth and fluffy.
Once the cupcakes are completely cool, frost them generously with the cream cheese frosting using a knife or piping bag.