Preheat oven to 350°F (175°C) and line a baking sheet with parchment paper.
In a medium bowl, whisk together flour, baking soda, salt, cinnamon, and nutmeg. Set aside.
In a large bowl, beat the butter, brown sugar, and granulated sugar together until light and fluffy.
Add in the egg and vanilla extract, mixing until fully incorporated.
Gradually mix in the dry ingredients until just combined.
Stir in the grated carrots, walnuts, and coconut if using.
Drop small spoonfuls of dough onto the prepared baking sheet, spacing them 2 inches apart.
Bake for 10-12 minutes, or until the edges are lightly golden.
Remove from the oven and let the cookies cool on the baking sheet for 5 minutes before transferring to a wire rack.
In a large bowl, beat the cream cheese and butter together until smooth.
Gradually add the powdered sugar and vanilla extract, mixing until creamy.
Once the cookies have fully cooled, spread a layer of cream cheese frosting onto the flat side of one cookie.
Place another cookie on top, gently pressing down to create a sandwich.
Repeat with the remaining cookies and frosting.