I got the same error, I managed to split the js file in two, the variables that I was exporting to the server stays on the original file and the all the other client-side code goes in another file . Also using Vanilla JS and Node.