Environment variables are always undefined in VueJs application

喜欢而已 提交于 2020-06-17 03:56:45

问题


I am trying to create some environment variables for my application but they are always undefined for some reason. I followed some guides and did the following

Created a file called .env added the following into the file

VUE_APP_MY_ENV_VARIABLE = myValue

In my App.js file added the following:

beforeMount(){
  console.log(process.env.VUE_APP_MY_ENV_VARIABLE)
}

ran npm run serve but the variable always comes as undefined. I also ran npm run build and npm run serve multiple times but it ain't working for some reason.

来源:https://stackoverflow.com/questions/61370527/environment-variables-are-always-undefined-in-vuejs-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!