Prepare the Muffin Pans: Preheat the oven to 350°F (175°C), then line two standard muffin pans with paper liners and lightly spray the liners with non-stick baking spray. Set the prepared pans aside.
Combine the Wet Ingredients: In a large mixing bowl, whisk together the melted coconut oil, applesauce, granulated sugar, packed light brown sugar, salt, room-temperature eggs, cinnamon, cardamom, ginger, allspice, cloves, and black pepper until well combined.
Mix the Dry Ingredients: In a separate bowl, combine the all-purpose flour and baking soda, making sure the baking soda is evenly distributed throughout the flour.
Finish the Batter: Add the flour mixture to the bowl of wet ingredients and fold gently with a spatula until incorporated. Fold in the finely grated carrots and mix only until the batter is just blended.
Fill the Muffin Pans: Divide the batter evenly between the prepared liners, filling each one approximately three-quarters full.
Bake the Cupcakes: Bake the cupcakes one pan at a time for 19 to 20 minutes, or until a toothpick inserted into the center of one of the middle cupcakes comes out clean.
Cool in the Pan: Place the baked cupcakes in their pan on a wire cooling rack and let them cool for 10 minutes.
Cool Completely: Remove the cupcakes from the muffin pan and transfer them to the wire rack. Allow them to cool completely before adding the frosting.
Beat the Cream Cheese Mixture: Place the very soft cream cheese and butter in the bowl of a stand mixer fitted with the paddle attachment, or use a large bowl with an electric hand mixer. Beat on medium speed for about 2 minutes, until completely smooth. Add the Sugar: Reduce the mixer speed to low and gradually add the sifted confectioners’ sugar along with the salt. Continue mixing until all of the sugar has been absorbed.
Whip the Frosting: Increase the mixer speed to medium-high and beat for 1 to 2 minutes, or until the frosting is smooth and very fluffy.
Frost the Cupcakes: Once the cupcakes are completely cool, spread the cream cheese frosting over the tops or transfer the frosting to a piping bag and pipe decorative swirls.
Add the Nuts: Sprinkle the finely chopped toasted pecans or walnuts over the frosting, if desired.
Store the Cupcakes: Keep the covered cupcakes refrigerated for up to 3 days.