"define" is not defined in .js

I’m getting the error ““define” is not defined” in my .js code, but only in the glitch editor, it seems to work fine on visual studio. I feel like i’m missing something really basic, but I just can’t think what it is!

Any help or pointers are welcome!


Maybe this can help:

It kind of does, but if it it’s a dependencies issue then I don’t think I can help that in glitch can I?

Well, I think that if it is a dependency, maybe there’s some catch in it’s documentation

1 Like

Standard JavaScript does not have a define function, so you may need to hunt down what allowed you to use it in vs code.

If memory serves correct, define was a requirejs mechanism for creating modules back when nothing had modules built in (before ES modules or even Node.js!) so if this is an older codebase you might just need to load whatever the latest version of requirejs is (2.3.6 it looks like from cdnjs).

If it’s a new codebase, of course, it’s probably not requirejs and you’ll want to have a look at where VS code thinks define lives: if you right-click on it and pick “go to definition” you should jump to where it’s defined, and the file path “breakcrumb” in the top of VS code should show you which file you’re now in, which is usually enough to tell which dependency/dependencies are involved.


This is great and gives me a clear way to troubleshoot, thanks.

1 Like