Static GitHub Issues

[1323] How do I access environment variables in a component?

prev: Define helper file available in every component
next: Shallow routing

I can't find a way to access environment variables (especially within a component). I created a brand new project with:

vue init nuxt/starter new-project
cd new-project
npm install
npm run dev

nuxt.config.js

module.exports = {
  ...
  env: {
    hey: 'hey'
  }
}

pages/index.vue

<script>
import Logo from '~/components/Logo.vue'

export default {
  components: {
    Logo
  },

  mounted () {
    console.log(process.env)
  }
}
</script>

console.log() prints an empty object. I read in the documentation that you could access environment variables with process.env. What am I doing wrong? :)

I am using the latest version of nuxt.js (nuxt@1.0.0-rc3) and my version of node is 8.2.1.

<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c1172">#c1172</a>)</em></sub></div>