Preheat your oven to 350°F (175°C). This step is crucial as it ensures that your cupcakes bake evenly. While the oven is heating, spray a 12-count muffin pan very well with floured cooking spray or use cupcake liners. I prefer the spray as it helps to avoid the mess that comes from liners.
In a large mixing bowl, whisk together the first eleven ingredients, from the eggs to the salt. Make sure they are well combined; this will help build a nice structure in your cupcakes.
Next, add in the flour, baking powder, and baking soda. Stir gently until just combined; you want to avoid overmixing, which can lead to dense cupcakes.
Now it’s time to fold in the grated carrots, and if you’re using them, the raisins and nuts. Gently mix until the carrots are evenly distributed throughout the batter.
Turn the batter out into the prepared muffin pan, filling each cavity between two-thirds and three-fourths full. Be careful not to exceed three-fourths full, as they may overflow while baking. You might have some batter left over for an extra cupcake, which is always a nice bonus!
Bake for about twenty minutes or until the cupcakes are domed, set, and springy to the touch. A toothpick inserted in the center should come out clean or with just a few moist crumbs.
Allow the cupcakes to cool in the pan for about fifteen minutes. After that, carefully remove them and transfer them to a wire rack to cool completely. This step is vital to prevent sogginess.
While the cupcakes are cooling, prepare the frosting. In a mixing bowl, beat together the cream cheese, butter, and vanilla extract on high power until well combined and fluffy, which should take about three minutes.
Slowly add the confectioners’ sugar while mixing. Adjust the sugar quantity based on your desired frosting consistency. If it becomes too sweet, you can always add a little more cream cheese to balance it out.
Finally, frost the cooled cupcakes. I like to spoon about two tablespoons of frosting onto each cupcake, but you can also pipe it if you prefer a fancier look. If you have extra frosting, store it airtight in the refrigerator for a few weeks.