Preview panel fails, but separate Chrome tab works fine?



Hi folks,

when I view my code at

it works fine. Life would be just a fraction easier if I could view the same code in the preview panel directly in the IDE. However, when I try to do that, I get:

Error in line 139: Uncaught Error: Uncaught SyntaxError: Unexpected token <

I can’t find where this error is, or what causes it in the preview tab, or why it the code works perfectly in a separate Chrome tab but won’t work in the preview tab. They should both be viewing the same file and running the same process?

OK, seems to be the node.js default runner:

Debugger listening on port 15454
(function (exports, require, module, __filename, __dirname) {

SyntaxError: Unexpected token <
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:413:25)
at Object.Module._extensions…js (module.js:452:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.runMain [as _onTimeout] (module.js:475:10)
at Timer.listOnTimeout (timers.js:89:15)

When I switch to a fresh apache/php runner, then there’s no error in the console? Getting confused now… :frowning:




I’m afraid we might need more context before we can advise. Can you post part of the javascript file you’re trying to run as the node server? If you could post a screencast showing the issue, that would be awesome! :slightly_smiling:



It’s a straight github clone of openjscad. If you try to preview either min.html or index.html you’ll hit the same error.


this is a bug in
this.baseurl = document.location.href; and then baseurl + “filename” doesn’t work if baseurl has ?foo=bar in it


Why does it work in a separate browser tab? I’ve had this bug a few times with different projects.

If it works in another browser tab perfectly, works perfectly well when installed on a server, I’d suggest it’s your preview in the IDE that needs fixing?


It doesn’t work when you open it with ? in the url

the url parameters are needed to enable live editing of the preview, you can disable live preview from the preview options menu if you wish

note also that baseurl is handled properly a few lines above the broken code


That’s fab, replaced the code you suggested and it works. I’ll suggest that fix to the project developers.