The Javascript code inside function nodes cannot be debugged, but if you create your own custom node then you can debug it (like you can debug all other Node-RED nodes). I have explained here how you can debug Node-RED using a Chrome debugger, in case you ever need it...