[Bug] Inter-file javascript variables causing an error

I have created a project where I am attempting to use multiple javascript files. I imported them into my html file and everything works as it is supposed to. However, if I try to use variables from one file in another file, I get an error message from Glitch saying that my variables aren’t defined. Given that my code runs as expected, this is a glitch with Glitch (:slight_smile: ). See my example here-https://humorous-simplistic-tuck.glitch.me/ In one.js I declared a variable, x, with a value of 5. In two.js I declared a variable, y, with a value of x+5 then console.logged y. As expected, “10” is logged to the console. However, in the editor Glitch still gives me an error saying x is not defined.

Going to move this to #feedback feedback as this seems like a bug.

Ok, thanks! Sorry, I looked for a bug section but didn’t find one :slight_smile:

1 Like

I suppose feedback is the closest thing to a bug.

You can also make a post of the CodeMirror forum as this relates to the CodeMirror editor.

This also happens when using socket.io for the client side. As socket.io is in an other file, the socket variable is never defined in the outside and is marked as an error in the editor but works fine in the browser.

Add the code

/* global myvar1 myvar2 etc */

to the to of your files

1 Like

sorry, doesn’t work :expressionless:

Sorry, nvm, it works!

1 Like