-
-
Notifications
You must be signed in to change notification settings - Fork 6.3k
Env variables don't seem to load from a .env file on the new cli #767
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Only variables that starts with |
Why? It makes my API keys very longs. |
Why is this not at the very top part of the documentation? Especially where you give your example
FOO should be VUE_APP_FOO Edited: |
Yes I also overlooked I was yelling on myself 'why it's not working!' like 10 minutes and eventually came here READ THE DOCUMENTATION |
For those who arrived here looking for a solution, but already have your variables prefixed with |
This should be stressed out in the docs, I spent two hours figuring out why the documented example was not working... |
I understand that the prefix is a good thing to have when your Vue app is coupled with another framework like Laravel, but when the app is standalone, the prefix requirement is a bit exagerated no? Is there any other reason for the hard requirement? As I can see, we are not the first to overlook the requirement, and the docs are still showing |
Use touch to create your environment files. |
In development mode, double check that the env file name is correct(not misspelled): ".env.development" or ".env.development.local". |
Totally agree with this. |
To anyone who is still not getting it to work, please make sure your env files (.env, .env.development, .env.development.local, .env.production) have a They started working after changing to |
still freaking undefined! |
This is working for me fine on mac with VUE 2.6.11 in package.json and a .env. When running npm run serve, the .env loads and keys work. This same thing is not working on windows. |
Also make sure the .env file is in the root of the project, and not inside src |
The only thing that worked |
Version
3.0.0-alpha.5
Reproduction link
https://github.com/alexjoverm/vue-cli-env-reproduce
Steps to reproduce
Clone, run
npm install
andnpm run serve
on the repo provided.What is expected?
According to the code of the Service, some env variables should be loaded taken from a path, which are parsed on the loadEnv util.
By adding some logs, it seems that indeed the path it takes when running
npm run serve
is${rootDirectory}/.env.development
and${rootDirectory}/.env.development.local
. They're indeed loaded.So, by the
console.log(process.env)
line in the main.js file, those variables should be printed in the console.What is actually happening?
They're not listed in the console.
Note: if this is not supposed how is it possible to add env variables?
The text was updated successfully, but these errors were encountered: