# Error : "n is not a function"

**URL:** <https://discourse.processing.org/t/error-n-is-not-a-function/46936>\
**Category:** p5.js\
**Created:** [August 15, 2025, 8:40pm UTC](https://discourse.processing.org/t/error-n-is-not-a-function/46936 "2025-08-15T20:40:43Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![EricRogerGarcia](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ericrogergarcia/32/21029_2.png) [@EricRogerGarcia](https://discourse.processing.org/u/EricRogerGarcia)\
**Post date:** [August 15, 2025, 8:40pm UTC](https://discourse.processing.org/t/error-n-is-not-a-function/46936/1 "2025-08-15T20:40:43Z")

</div>

Hello,

I’ve translated in P5js with Gemini IA a big sketch written in Java to test if it was possible.

It almost works with some modifications.

But I still have an error : “Uncaught type error : n is not a function (p5.min.js:2")”

I don’t know if it’s related but I don”t have some things I write on the console in the Java version

Well I’m stuck here ! I don’t understand at all this error !

🙃

 ![error](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/e/b/eb8f47cbb3c0d5113d371e739e8666c04b1cf596.jpeg)

> **[PSE-Roadmap - EricRogerGarcia](https://ericrogergarcia.legtux.org/pse-roadmap)**
>
> PstarEngine is a small game and graphical user interface engine in 2 versions: Java and Javascript.
> Cours d'informatique à domicile au pays de Lorient . Créer un site internet - Fabriquer des jeux vidéo - Commencer à programmer avec Scratch,...

---

<div class="post-metadata">

**Author:** ![GoToLoop](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/gotoloop/32/86_2.png) [@GoToLoop](https://discourse.processing.org/u/GoToLoop)\
**Post date:** [August 15, 2025, 10:56pm UTC](https://discourse.processing.org/t/error-n-is-not-a-function/46936/2 "2025-08-15T22:56:07Z")

</div>

> [@EricRogerGarcia](#):
>
> n is not a function (p5.min.js:2")

W/o code, no idea. Anyways, for debugging, don’t use the “.min.” version!

Grab the non-minimized version instead: [https://Unpkg.com/p5/lib/p5.js](https://Unpkg.com/p5/lib/p5.js)

---

<div class="post-metadata">

**Author:** ![EricRogerGarcia](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ericrogergarcia/32/21029_2.png) [@EricRogerGarcia](https://discourse.processing.org/u/EricRogerGarcia)\
**Post date:** [August 16, 2025, 6:28am UTC](https://discourse.processing.org/t/error-n-is-not-a-function/46936/3 "2025-08-16T06:28:11Z")

</div>

ok, done (thanks)

Now, I have

 ![errors2](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/3X/0/2/02c3735a19c351f78ea6bbc620bff836dbc46d18.jpeg)

😶‍🌫️ … and it almost doesn’t work anymore !

P.S. I may try to replace the part I suspect (where I write to the console) with an old version I wrote myself (I think I didn’t change this part since). Gemini may not have done a good job on it

---

<div class="post-metadata">

**Author:** ![EricRogerGarcia](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ericrogergarcia/32/21029_2.png) [@EricRogerGarcia](https://discourse.processing.org/u/EricRogerGarcia)\
**Post date:** [August 16, 2025, 6:57am UTC](https://discourse.processing.org/t/error-n-is-not-a-function/46936/4 "2025-08-16T06:57:23Z")

</div>

Gemini did not write a ‘let’ for many variable declarations. It is perhaps this that causes problems because if variables that must be local are declared as global, it will work in most cases… but not all!

I”m going to try again with Gemini,

see :

> **[PSE-Roadmap - EricRogerGarcia](https://ericrogergarcia.legtux.org/pse-roadmap)**
>
> PstarEngine is a small game and graphical user interface engine in 2 versions: Java and Javascript.
> Cours d'informatique à domicile au pays de Lorient . Créer un site internet - Fabriquer des jeux vidéo - Commencer à programmer avec Scratch,...

---

<div class="post-metadata">

**Author:** ![EricRogerGarcia](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ericrogergarcia/32/21029_2.png) [@EricRogerGarcia](https://discourse.processing.org/u/EricRogerGarcia)\
**Post date:** [August 16, 2025, 7:41am UTC](https://discourse.processing.org/t/error-n-is-not-a-function/46936/5 "2025-08-16T07:41:36Z")

</div>

Thank you to everyone: it feels good to no longer be completely alone on my project!

💓

---

<div class="post-metadata">

**Author:** ![EricRogerGarcia](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/ericrogergarcia/32/21029_2.png) [@EricRogerGarcia](https://discourse.processing.org/u/EricRogerGarcia)\
**Post date:** [August 16, 2025, 11:59am UTC](https://discourse.processing.org/t/error-n-is-not-a-function/46936/6 "2025-08-16T11:59:01Z")

</div>

## I’ve redone it with Gemini with this prompt

Do the translation from Processing to P5JS of the code following line:  
// DEBUT CODE  
Translate only the syntax (do not change the code, do not modify the functions except for the functions of P5js, do not add functions)  
Do not add or edit comments.  
Precede the declarations of new variables (those that are preceded by a variable type name in Java such as String, float, Boolean, PFont, PImage, int …) with the JavaScript instruction let  
For file uploads, precede the filenames with their path, namely:  
data/  
Use the strict javascript mode.  
The part of the code located between the line  
//---------------- JS debut-------------  
and the line  
//---------------- JS Fin-------------  
is not to be translated because it is already in P5js  
Variables declared in java but not initialized to a value must be declared and initialized to the null value.

// DEBUT CODE

and all the code here

## And…

… and it works fine without strict mode with just a function name to change

no error

## With strict mode

just an error but it”s mine because it is in the JS part !

Fixed!  
Everything works without error in strict mode everywhere!!!

😀

I’m so glad !

We can use AI for transpilation sometimes to save time.  
(provided that it can also be done without!)
