How to get p5js library into account in js parser

I use glitch with p5js library and your internal parser did’nt recognize the function name of p5js. Is there anyway to take a library into account during parsing ?
Best regards


if i am correct in that the issue is it’s looking for a global called “p5js”, you can add /* global p5js */ to the first line in the file to get rid of that error. if that doesn’t help, let me know the project name and I can check it out for you!

Hi Jenn,

Here is my project.!/remix/p5jsplay
It use p5js library ( I declare this library in index.html file.
When I go, for example, in the sketch.js I got the error “createCanvas is not defined”
Is there a way to recognize this function name belonging to p5js library ?
Thanks for your help

you would list all the variables that are not defined in that file/scope (see my remix at!/night-text?path=public/sketch.js:19:1)

and just so you know, the error is in the practice of using global variables, which happens to be necessary when using p5 like this - it’s not a programming error on your part!

oh of course I knew this was’nt an error from glitch :wink:
I just wanted to know how to skip this error message.
Is there a way to include a js file with this global variables definitions ?
So my students will not be obliged to include such line in their program ?
Best regards

You says “which happens to be necessary when using p5 like this”
Do you know an other way using p5 in glitch ?

you can add p5 as a dependency in package.json and require it in your client side js - but you’d need to use something like browserify to get that “require” function

OK Jenn
I’ll look at this solution.
Thanks for your help