Is most probably because the node (first parameter) that you want to insert in DOM is null or undefined. You can reproduce this error by running:
document.body.insertBefore(null, document.body.firstChild);
You must check the line that returns the element reference to draggable
:
document.querySelector('.dragging') // must be not null, you can run in console and/or debug using the devtools to see what is happening
CLICK HERE to find out more related problems solutions.