1

I have .env file in the root of my project in Vue3. In the components folder, I have Card.vue and this code

console.log(process.env.FOO)

But in browser, it shows undefined.

2 Answers 2

4

Variables must start with VUE_APP, hence

`VUE_APP_FOO`
Sign up to request clarification or add additional context in comments.

2 Comments

It shows this 'VUE_APP_FOO' is not defined while running npm run serve
Please, first change name of the variable to VUE_APP_FOO in .env file, and then refer to it.
1

Having a similar problem here. I'm usnig VUE_APP_FOO to set the variable in .env but it's still undefined when console.log(process.env.VUE_APP_FOO). Using Vue2 (Vue cli 4.5.11)

1 Comment

In my case solved checking for a annoying misspelling and restarting. @ToklCz try console.log(process.env) for debugging

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.