Preheat the Oven: Set your oven to 350°F (180°C). Prepare a 9-inch square baking tin by lining it with parchment paper, allowing for some overhang for easy removal later.
Mix Wet Ingredients: In a large bowl, whisk together the light brown sugar, oil, eggs, and vanilla extract until smooth and well combined.
Combine Dry Ingredients: Sift together the gluten-free flour, baking powder, baking soda, xanthan gum (if using), salt, cinnamon, ginger, and nutmeg in a separate bowl.
Make the Batter: Add the dry ingredients into the wet ingredients and whisk until smooth. Avoid over-mixing. Then, fold in the grated carrots and walnuts until evenly distributed.
Bake the Cake: Pour the batter into the prepared baking tin, smoothing the top with a spatula. Bake for about 35 minutes, or until the cake is golden-brown and a toothpick inserted into the center comes out clean.
Cool the Cake: Allow the cake to cool in the tin for 10–15 minutes before transferring it onto a wire rack to cool completely.
Prepare the Frosting: While the cake is cooling, beat the cream cheese in a bowl until smooth. Add the heavy cream, powdered sugar, and vanilla extract, and whisk until soft peaks form.
Frost the Cake: Once the cake has cooled, spread the cream cheese frosting evenly over the top. Garnish with chopped walnuts if desired.
Serve and Enjoy: Slice the cake and enjoy!