Your description code come on board is wrong is not very helpful.
So check the usual problems:
powersupply not stable
reset the board manually several times
try with other baudrate for flashing
did you try to flash one of the examples from ESP-IDF ?
last not least, the board could be damaged
Anyway, sounds like a problem of ESP32 and not of Espruino.
Try to get some help here https://esp32.com/
Please have in mind to give them a more detailled/helpful description of your problem.
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
Your description code come on board is wrong is not very helpful.
So check the usual problems:
Anyway, sounds like a problem of ESP32 and not of Espruino.
Try to get some help here https://esp32.com/
Please have in mind to give them a more detailled/helpful description of your problem.