Env variables don't seem to load from a .env file on the new cli
See original GitHub issueVersion
3.0.0-alpha.5
Reproduction link
https://github.com/alexjoverm/vue-cli-env-reproduce
Steps to reproduce
Clone, run npm install
and npm 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?
Issue Analytics
- State:
- Created 6 years ago
- Comments:16 (1 by maintainers)
Top Results From Across the Web
dotenv file is not loading environment variables - Stack Overflow
Show activity on this post. Try this: const dotenv = require('dotenv'); dotenv. config({ path: process.
Read more >5 reasons why your .env environment variables don't work
1. Your framework doesn't automatically load .env files. ... While some frameworks and packages come built-in support for environment variables ...
Read more >Introduction to environment variables - CircleCI
Use environment variables to set up various configuration options, and keep your set-up secure with secrets, private keys, and contexts.
Read more >Automatically Load Environment Variables in Flask
Learn how to use python dotenv to automatically load environment variables into your Flask projects.
Read more >Using Environment Variables in Python for App Configuration ...
You may need to check if an environment variable exists, but don't necessarily care about its value. For example, your application can be...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Only variables that starts with
VUE_APP_
are loaded on the client: https://github.com/vuejs/vue-cli/blob/dev/packages/%40vue/cli-service/lib/util/resolveClientEnv.js#L1Why? It makes my API keys very longs.