Line a 9x9 inch baking pan with parchment paper. Set aside.
In a medium saucepan, combine butter, sugar, and cocoa powder. Place over medium heat until ingredients have melted.
Add egg and stir constantly over medium heat for 2 minutes. Mixture will look scrambled, Remove from heat and add graham cracker crumbs, coconut, and pecans.
Press mixture into the bottom of the prepared baking pan, and set aside.
Raspberry Filling
Place raspberries and lemon juice into a small saucepan over medium heat. Cook raspberry mixture until the berries soften, juices juices are released, and puree has thickened, about 2-3 minutes.
Remove from heat and push raspberries through a small sieve into a fresh bowl to remove the seeds. Set aside.
In a large bowl, beat butter and sugar together until well combined. Mix in raspberry puree.
Spread raspberry filling over the bottom layer. Cover and store in the refrigerator until it firms, at least 2 hours or overnight.
Chocolate Topping
Using a double boiler, or a bowl over a pan of boiling water, melt chocolate and butter together until melted and smooth.
Spread chocolate over the chilled raspberry layer. Cover and return to the refrigerator for at least 1 hour or until the chocolate has firmed.
Cut Nanaimo bars into squares or rectangles. Store in an airtight container in the refrigerator. These are meant to be eaten cold.
Notes
Instead of pecans, you can use walnuts or almonds.
You can make this ahead of time. The raspberry puree can be made up to 3 days before. The bars up until after the raspberry filling is added, can be made up to 2 days before. The bars can me stored in the refrigerator for up to 5 days.
Use salted butter or unsalted butter in this recipe. It doesn't make much of a change.
Instead of a raspberry filling, use a blueberry, blackberry, strawberry, or a mix berry filling!
Store these in the refrigerator. They will be too soft if left out at room temperature too long.