question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Env variables don't seem to load from a .env file on the new cli

See original GitHub issue

Version

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:closed
  • Created 6 years ago
  • Comments:16 (1 by maintainers)

github_iconTop GitHub Comments

137reactions
yyx990803commented, Feb 2, 2018

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#L1

47reactions
e200commented, Oct 17, 2018

Why? It makes my API keys very longs.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found