For me, simply rebuilding the panel BEFORE running yarn dev / yarn start helped.
This helped me:
rm -r .cache build node_modules yarn.lock package-lock.json
yarn
yarn build
yarn dev
From there you can try if it all works and then CTRL+C quit the process and continue with your production build and pm2.