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.

[docs] Availability of process environment variables

See original GitHub issue

When using the Quasar CLI, if I have:

data () {
	return {
		process: process,
		env: process.env
	}
},

and in the template:

{{ process.env.DEV }} / {{ env.DEV }}

it ouputs : / true (seen in the browser and in cordova)

So AFAIK it means that process or env itself is reassigned at some point, and only keeping a direct reference to the process.env object at the creation of the component works.

This is the console log of process later on when the env object is empty:

image

If it’s not a bug I believe it should be documented on this page: https://quasar.dev/quasar-cli/cli-documentation/handling-process-env.

Thank you

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
MartinManevcommented, Aug 22, 2019

The process object is only available in the context of a node.js application. Webpack automatically removes it for you.

For Vue CLI there is some documentation here: https://cli.vuejs.org/guide/mode-and-env.html#modes

Note that only variables that start with VUE_APP_ will be statically embedded into the client bundle with webpack.DefinePlugin.

How WebPack’s DefinePlugin works is explained here: https://webpack.js.org/plugins/define-plugin/

The Quasar CLI works a bit differently than the Vue CLI, but I believe the idea is the same. There is even a section that explains how it (Webpack) strips out code when running in different modes: https://quasar.dev/quasar-cli/cli-documentation/handling-process-env#Stripping-out-code

Edit: The above Quasar CLI documentation page does not mention Webpack at all. I think it should be updated to be more descriptive.

1reaction
nothingismagickcommented, Aug 22, 2019

Be careful, especially if you are using either of the @quasar/qenv or @quasar/dotenv app extensions in the Quasar CLI (which is what we recommend).

While @MartinManev makes a good point, he is comparing Vue CLI to Quasar CLI. They are very different things.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Built-in environment variables | Workflows - Google Cloud
List of built-in environment variables. You can use the following built-in environment variables: GOOGLE_CLOUD_LOCATION : The location of the workflow.
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 >
Environment variables to configure the AWS CLI
Environment variables provide another way to specify configuration options and credentials, and can be useful for scripting or temporarily setting a named ...
Read more >
Environment variables - Workers - Cloudflare Docs
​​ Adding environment variables via wrangler ... Environment variables are defined via the [vars] configuration in your wrangler.toml file and are ...
Read more >
Environment Variables - The Java™ Tutorials
The conventions for setting and using environment variables vary between operating systems, and also between command line interpreters. To learn how to pass ......
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