Here are two options:
Using ethers.js - the example below uses a mnemonic
ethers wallet documentation
const ethers = require('ethers');
let mnemonic = "YOUR MNEMONIC";
let mnemonicWallet = ethers.Wallet.fromMnemonic(mnemonic);
This doesn't seem to be included in web3, but has been added to the list of enhancements ...
Found my answer.
On metamask, I can export private key of selected account
Click on the threedots
Click on Account details
Click on export private key.
It now ask you a password: it's the Metamask password. It's specific to metamask.
Then it will show you the private key.
Keep it absolutely private, do not share, do not save on cloud!