P5 error not defined deploy in Vercel, but in Vite in local works fine

Not showing p5,js sketches as Vercel gives an not defined error, in Vite works fine.
Also would like to go to myrpoject/docs and show the jsdoc documentation.

Load my project, and sketches are not shown…

With vite works fine, but in vercel i got an error when i deploy to Vercel

Uncaught ReferenceError: p5 is not defined
    Nn https://pacman2024windows.vercel.app/assets/index-Df26wdtU.js:1776
    An https://pacman2024windows.vercel.app/assets/index-Df26wdtU.js:1
    <anonymous> https://pacman2024windows.vercel.app/assets/index-Df26wdtU.js:1776

As vite in local i want to access my index.html showing some p5.js sketches, and then if i go to myproject/docs show de index of documentation.

Structure of my project;

This is the caling of scripts in index.html in root project:

 <script type="module" src="js/libraries/p5.min.js"></script>
    <!--Carreguem moduls-->

    <!--Carreguem sketch-->
    <script type="module" src="/js/sketch.mjs"></script>
    <script type="module" src="/js/secondsketch.mjs"></script>

I really need help im a teacher in vocational education, and with my students we are stuck.

Thanks

It looks like p5 is expected but missing from the deployed version of the app. I would double check the package.json file to be sure the package is included.

If you need more help, please share your public repo or a minimal reproducible example. That will let us all work together from the same code to figure out what’s going wrong

1 Like

p5.js is located in root/js/libraries/p5.min.js → the path should work fine because in local Vite its loaded without problems. I think is a static file, because it contents all the functions of p5.js library.
I downloaded a zip file from p5.js : Descargar → Complete library… is a zip file and i uncompressed.

I thought that all files with type=“module” in root/index.html would be loaded in Vercel.

Can you access the code in the vercel dashboard ? or may i add you ?

The minimal reproducible example is what i told before: index.html pointing to a j5 library, and put the file in the correct path, and Vercel cant find or load the library → gives error p5 is not defined.

Thanks for your help

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.