Uncaught SyntaxError: Unexpected token '*'

Description of the problem:

I am trying to move an existing psychopy experiment online. The experiment works perfectly well off-line, but when trying to run it online, I get stuck on the “initializing experiment” page. I opened up the HTML sidebar and found the following message: "Uncaught SyntaxError: Unexpected token ‘*’ ".
I’ve tried to locate the * in the code, and I found the following instances:

import { PsychoJS } from './lib/core-2020.1.js'; import * as core from './lib/core-2020.1.js'; import { TrialHandler } from './lib/data-2020.1.js'; import { Scheduler } from './lib/util-2020.1.js'; import * as util from './lib/util-2020.1.js'; import * as visual from './lib/visual-2020.1.js'; import * as sound from './lib/sound-2020.1.js';

and

frameRemains = 0.0 + 1.0 - psychoJS.window.monitorFramePeriod * 0.75; // most of one frame period left if (PracFixationDot.status === PsychoJS.Status.STARTED && t >= frameRemains) { PracFixationDot.setAutoDraw(false);

I read that you cannot import python libraries to JS, so, just to test, I commented out all instances of “random.” that I had in my experiment, but I am still getting the same initialization error.

Can anyone offer any direction on this issue? I’ve tried running the experiment in chrome and firefox and receiving the same issue (stuck on initializing). I am at my wit’s end. Is there a way to identify the exact line where the problem is arising?

Did you remove the actual import statement in your code?

Best wishes,

Wakefield

Hi Wakecarter,
Thanks for your response. Yes I removed the import statement for “import random”.

Edit: Turns out I missed an import statement hiding in a late routine. It’s running now. Thanks!

1 Like