#Environment variable doesn't work

13 messages · Page 1 of 1 (latest)

marble hedge
#

Hi, I set up an environment variable following the step by step description on Scrimba, but it doesn't work.
Did anyone else have that problem and could tell me how to fix it?

Thank you!

Frida

wary ember
#

Try importing your script as a module (add type="module" inside of the </script> tag).

sweet hornet
#

Please provide code.

#

Also if it helps try. console.log(process.env.YOUR_ENV_VARIABLE);

marble hedge
#

Thank you guys. I can make it work just fine in my code editor and local environment. I am talking about the Scrimba editor... I am sorry for not making that clear.

#

@wary ember@sweet hornet

wary ember
marble hedge
#

@wary emberThank you, I do that
<script src="index.js" type="module"></script>
The variable just logs undefined..

#

I rewrote the challenge in my vs code... That is a prime example why I usually avoid writing in the scrimba editor.. They run dependencies which I cannot see or access and the editor doesn't reflect working on real world projects.. It works in my local. So I will stick with that.

#

Thank you though!

#

..If I'd share the scrim link, anybody would have access to the environment variable. That is probably a very bad idea 😉

wary ember
marble hedge
#

@wary ember Well yea, that's true I guess. It would only show the assigned const ..