How do you fix anything to a wooden component using a metric machine screw?
The answer is to fit a captive nut as follows:
Drill a hole of the right size to accept the nut barrel, then drive the nut's projecting teeth into the wood using a hammer and fairly gentle force; the captive nut is correctly fitted when its disc rests squarely on the surface of the wood.
Tip: place a piece of scrap wood under the workpiece when drilling the hole, to prevent untidy edges where the drill exits the wood.