psychopy.org | Reference | Downloads | Github

How to use my own modules on pavlovia

URL of experiment: https://pavlovia.org/run/xfang/exp7/html/

Description of the problem:
I need some js modules including one called papaparse, I tried to put it in the html folder but that doesn’t seem available.


Just started learning javascript this week. Pointers appreciated.

my importing line
import * as Papa from './resources/node_modules/papaparse/papaparse.js';
it works on my desktop in node.js

I tried to source papaparse from cdnjs like the way you do external libraries


and then import it in Cindy.js by import * as Papa from 'https://cdnjs.cloudflare.com/ajax/libs/PapaParse/5.0.0/papaparse.min.js';
got an error and stuck at loading

Hi @Xinzhu-Fang, this should work without trying to import the libraries in the JS code. Just add the external library to the HTML, as you have done, and you should be able to use the library in your JS.

I actually tried that considering Tone is called directly without being imported here https://pavlovia.org/lib/sound.js. The reason that I got a reference error was I called papaparser instead of Papa. Simply removed my “importing line” and now it works!!
Thank you