USB.setConsole(true); when USB isn't connected is totally fine - anything that gets written to USB will just get thrown away when Espruino knows the connection is down.
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.
It could just be a flaky USB power supply?
USB.setConsole(true);
when USB isn't connected is totally fine - anything that gets written to USB will just get thrown away when Espruino knows the connection is down.