URL of experiment: https://gitlab.pavlovia.org/dillancellier/silent_cereal_builder/blob/master/silent_cereal_builder.js
https://pavlovia.org/dillancellier/silent_cereal_builder
Description of the problem:
Hello everyone!! Thank you in advance for any help. I am using Psychopy3 v2020.2.4.
It seems I am experiencing issues with the win variable in my PsychoJS code. The code works fine on Builder, but in running it online on Pavlovia, not so much.
At first, I had an error-- ''win" was not defined. I first came across this post: Pavlovia Error Code: Can't find variable: win
So i added the recommended lines of code according to the crib sheet (youâll see them in my JS script on lines 102-105 in the gitlab viewer):
const thisExp = psychoJS.experiment;
const win = psychoJS.window;
const event = psychoJS.eventManager;
const shuffle = util.shuffle;
I am new to JavaScript, so hopefully I did this correctly.
However, now Iâm getting a new error:
âTypeError: Cannot read property â_psychoJSâ of undefined,â and Iâm guessing it is still something to do with the win variable since it errors out at the first instance of an TextStim.
I found this post as well: Type Error: Cannot read property '_psychoJS' of undefined
But wasnât sure how to apply that solution to my issue.
Thank you so much for any insight! 
Hey Dillan, welcome to our forum!
Have I got it right that youâre directly editing the JS generater by the PsychoPy builder?
Hi Thomas!
Thanks for your reply-- no I wasnât. I was editing the compiled JS script in a text editor before pushing it to Gitlab.
But then I did try adding it just using the Builder custom code component, and it did not seem to make a difference.
Sounds like multiple things are going on here. Things like core.wait and win.flip work very differently in PsychoJS than in PsychoPy, so I guess that besides the error youâve got now, youâll have a long way to go before making this code work.
I recommend starting over. Build your experiment completely in the PsychoPy Builder; have it generate the PsychoJS code; and while developing, frequently test whether your experiment keeps working.
Here are some links:
Hi Thomas,
Thank you so much for your suggestions! To be clear, I did build the experiment entirely in the PsychoPy Builder and let it generate the PsychoJS code (the only exceptions to this being to insert the four lines of JS code recommended in the crib sheet after a JS script of the whole experiment had been compiled)â
Are you suggesting that I should not insert any custom python code components into the Builder experiment? This custom code component is where the win.flip and core.waitâs you see are coming from.
Thanks again for your input, and Happy Holidays!
Edit: After looking through some of your links, I see that maybe there are problematic aspects of my custom code that can be worked around. Thanks!! Hopefully that is the root of this error.
1 Like
Hey again,
Hope you had a nice Christmas. Actually Iâll have a brief period off starting now, but I read you got a some ideas for a workaround. Good luck debugging; if it doesnât work out, speak you in a couple of days!
Best, Thomas