I'm using @vue/cli 4.2.3 but when I create a .env file in my project root folder and declared a new env variable in it then print it in any component it returns undefined.
My env variable is like
VUE_APP_NAME=VALUE
and I'm calling it like
console.log(process.env.VUE_APP_NAME)
and the result is always undefined
Any help, pls?
Asked
Active
Viewed 557 times
1

ahmed khatab
- 11
- 1
-
Does this answer your question? [Vue-cli 3 Environment Variables all undefined](https://stackoverflow.com/questions/55510326/vue-cli-3-environment-variables-all-undefined) – Salim Mahboubi Mar 01 '21 at 17:33
1 Answers
1
With the information you give it seems that you are doing well.
- The file is in the root.
- The variable starts by
VUE_APP_
I would check that the .env file has no extension.

Vallemar
- 193
- 2
- 7
-
-
Supposedly not, but if you have disabled the file extension view you may have created a .txt. It is a supposition, I already tell you, by the data you put you are doing well – Vallemar Jun 16 '20 at 21:56
-