.env Variable quotation

Hello, friends

This might be a silly question but still I’m curious the use of quotation mark for .env variable. Is it better to use it or not? In the learning section, we should use quotation mark but in project (especially in Personal Library project), we are told not to use it.

Hello there,

I assume you are talking about:
This: ENV_VARIABLE="value"
Versus this: ENV_VARIABLE=value

If so, then, with the recent versions of Node etc. they are equal. With or without, it does not matter. All values are parsed based on the =, as well as the line terminator, and are used/represented as strings. However, this could become important depending on which environment you are using the variables. Eg. In non-unix systems (some Windows systems), it might be necessary to wrap your values within quotations.

Otherwise, with older systems dealing with environment variables, it is mandatory to wrap values within quotation marks. So, to be completely system/environment agnostic and cross-compatible, it is best to wrap the values within quotation marks. This is only needed, if you know your project will be used on any/older environments

Hope this helps

Thanks, now I got it.