import.meta.env but undefined in the console #15525
Replies: 4 comments 1 reply
-
Here is an example working: https://stackblitz.com/edit/vitejs-vite-nvdere?file=index.html&terminal=dev When asking this kind of questions, it is a good idea to share a reproduction so others can check it out. Maybe there is a typo somewhere for example? |
Beta Was this translation helpful? Give feedback.
-
that's my structure at the moment and my .env constants : Wanted to develop a request without hardcoding URLs, but it seems like the environment variables are not being overridden |
Beta Was this translation helpful? Give feedback.
-
Looks like the |
Beta Was this translation helpful? Give feedback.
-
I have the same problem (vite+svelte+framework7 app). console.log is both in the "home" and "about" components, see src/pages |
Beta Was this translation helpful? Give feedback.
-
Hi there.
I am trying to get a variable from
.env
file and log it (usingconsole.log()
) but returnsundefined
..env
file is at the root of my project..env
is namedVITE_REACT_APP_SERVER_URL
../src/app/app.jsx
like this:console.log(import.meta.env.VITE_REACT_APP_SERVER_URL);
File structure:
Please point to what I am doing wrong here. Thanks
Beta Was this translation helpful? Give feedback.
All reactions