How to use dotenv with Vue.js

前端 未结 3 1199
无人及你
无人及你 2021-02-19 01:43

I\'m trying to add some environment variables into my vue app.

here is content of my .env file, which is placed on root(outside src):



        
3条回答
  •  天命终不由人
    2021-02-19 02:04

    Try removing the spaces around the equal sign.

    VUE_APP_GOODREADS_KEY=my_key
    

    Also, try debugging like this:

    const config = dotenv.config()
    if(config.error){
      console.log('Could not load env file', config.error)
    }
    

    Reference: https://github.com/motdotla/dotenv#config

提交回复
热议问题