As @fanoush says, require("Storage").eraseAll() will get rid of everything - but if you had stuff in RAM then that will still run, and if it references stuff that was in flash you'll get the Got [ERASED] expected EOF error - a simple reboot will fix it permanently.
The easiest fix for that is actually just to do this to clear the device:
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.
As @fanoush says,
require("Storage").eraseAll()
will get rid of everything - but if you had stuff in RAM then that will still run, and if it references stuff that was in flash you'll get theGot [ERASED] expected EOF
error - a simple reboot will fix it permanently.The easiest fix for that is actually just to do this to clear the device: