Preheat your oven to 350°F (175°C). Grease a 9 × 9-inch baking dish with butter or nonstick cooking spray.
Peel the butternut squash, remove the seeds, and cut the flesh into evenly sized cubes. Place the cubes in a large saucepan and cover with water.
Bring to a boil and cook for about 15–20 minutes, or until the squash is fork-tender. Drain thoroughly and let it sit for a few minutes to release excess moisture.
Transfer the cooked squash to a large mixing bowl. Mash until mostly smooth, leaving a few small pieces if you prefer a little texture.
Add the melted butter, brown sugar, milk, beaten egg, cinnamon, nutmeg, salt, and vanilla extract. Stir until everything is evenly combined.
Spread the squash mixture into the prepared baking dish and smooth the top with a spoon.
In a separate bowl, combine the chopped pecans, flour, and brown sugar.
Pour in the melted butter and stir until the mixture forms small buttery crumbs. Sprinkle the topping evenly over the squash filling.
Place the baking dish in the preheated oven and bake for 25–30 minutes, or until the casserole is set around the edges and the pecan topping is lightly golden.
Remove from the oven and allow it to rest for about 5–10 minutes before serving. This gives the filling a little time to settle and makes serving easier.