Preheat the oven to 350°F (175°C). Grease a 9x13-inch baking pan or line it with parchment paper for easy removal.
In a large mixing bowl, whisk together the flour, sugar, baking powder, baking soda, cinnamon, nutmeg, and salt until well combined.
In another bowl, mix the vegetable oil, eggs, grated carrots, crushed pineapple, and vanilla extract until smooth.
Pour the wet ingredients into the dry ingredients and stir until just combined. If using, fold in the chopped walnuts or pecans.
Spread the batter evenly in the prepared baking pan. Bake for 30-35 minutes, or until a toothpick inserted into the center comes out clean. Allow to cool completely in the pan on a wire rack.
While the bars are cooling, prepare the cream cheese frosting. In a medium bowl, beat the softened cream cheese and butter together until smooth. Gradually add the powdered sugar and vanilla extract, mixing until creamy and well combined.
Once the bars are completely cooled, spread the cream cheese frosting evenly over the top. Cut into squares and serve.