You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should likely be reported to vuejs/core instead.
alessiogmonti
changed the title
Can't access environment variable in app files- returns undefined or NaN
Can't access environment variable in app files- returns undefined
Sep 29, 2022
VIte's .env does not support multiline values (#10149).
So import.meta.env.VITE_ETHERS has {. Also even if it is supported env variables are string and JSON.parse will be needed.
Describe the bug
I have created a .env file in the root directory with the variable "VITE_ETHERS" :
these are the entire content of the file.
console.log( import.meta.env.VITE_ETHERS.targetChainName)
returns undefined.I am not trying to access this variable outside my app source code, so I don't think I need to use loadEnv() in vite.config.js
Reproduction
https://stackblitz.com/edit/vitejs-vite-fqjcrb?file=main.js
System Info
Used Package Manager
npm
Logs
No response
Validations
The text was updated successfully, but these errors were encountered: