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.

Parse DotENV (.env) file with standard syntax

See original GitHub issue

Version

3.7.0

Environment info

Environment Info:

  System:
    OS: macOS Mojave 10.14.4
    CPU: (8) x64 Intel(R) Core(TM) i7-4770HQ CPU @ 2.20GHz
  Binaries:
    Node: 10.15.3 - /usr/local/bin/node
    Yarn: 1.13.0 - /usr/local/bin/yarn
    npm: 6.9.0 - /usr/local/bin/npm
  Browsers:
    Chrome: 74.0.3729.108
    Firefox: Not Found
    Safari: 12.1
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0-beta.3 
    @vue/babel-plugin-transform-vue-jsx:  1.0.0-beta.3 
    @vue/babel-preset-app:  3.7.0 
    @vue/babel-preset-jsx:  1.0.0-beta.3 
    @vue/babel-sugar-functional-vue:  1.0.0-beta.3 
    @vue/babel-sugar-inject-h:  1.0.0-beta.3 
    @vue/babel-sugar-v-model:  1.0.0-beta.3 
    @vue/babel-sugar-v-on:  1.0.0-beta.3 
    @vue/cli-overlay:  3.7.0 
    @vue/cli-plugin-babel: ^3.7.0 => 3.7.0 
    @vue/cli-plugin-eslint: ^3.7.0 => 3.7.0 
    @vue/cli-service: ^3.7.0 => 3.7.0 
    @vue/cli-shared-utils:  3.7.0 
    @vue/component-compiler-utils:  2.6.0 
    @vue/eslint-config-prettier: ^4.0.1 => 4.0.1 
    @vue/preload-webpack-plugin:  1.1.0 
    @vue/web-component-wrapper:  1.2.0 
    babel-helper-vue-jsx-merge-props:  2.0.3 
    eslint-plugin-vue: ^5.0.0 => 5.2.2 
    vue: ^2.6.10 => 2.6.10 
    vue-eslint-parser:  5.0.0 
    vue-hot-reload-api:  2.3.3 
    vue-router: ^3.0.3 => 3.0.6 
    vue-style-loader:  4.1.2 
    vue-template-compiler: ^2.5.21 => 2.6.10 
    vue-template-es2015-compiler:  1.9.1 
    vue2-transitions: ^0.3.0 => 0.3.0 
    vuex: ^3.0.1 => 3.1.0 
  npmGlobalPackages:
    @vue/cli: 3.6.3

Steps to reproduce

.env:

VUE_APP_FOO='BAR' # comment here, but get WTF value

What is expected?

process.env.VUE_APP_FOO === 'BAR'

What is actually happening?

process.env.VUE_APP_FOO === "'BAR'"

vue-cli3 current way for parse: https://github.com/vuejs/vue-cli/blob/9c1e797ac6/packages/%40vue/cli-service/lib/util/loadEnv.js#L13

maybe use https://github.com/motdotla/dotenv ?

syntax demo:

EC65871690577AAF53C675B4B517EEE2

image

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
Akryumcommented, Apr 28, 2019

Beaten by few milliseconds 😹

0reactions
Akryumcommented, Apr 29, 2019

@LinusBorg The issue was the inline comment. We use JSON.stringify internally to add the quotes, to if they were not removed by dotenv, you would end up with quotes inside the string.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dotenv tutorial - loading environment variables in JavaScript ...
Dotenv tutorial shows how to load environment variables in JavaScript using the dotenv module. ... Here are some basic parsing engine rules:.
Read more >
Dotenv File Format — Dotenvy v0.7.0 - HexDocs
env files (a.k.a. "dotenv") store key-value pairs in a format descended from simple bash files that exported environment variables. This implementation cleaves ...
Read more >
Loads environment variables from dotenv files - Hackage
After calling Dotenv.load , you are able to read the values set in your environment using standard functions from System.Environment or System.
Read more >
environment variables - What language is a .env file written in?
The file simply serves as a 'text' configuration, which is parsed by the module. The parsed configuration is used as a basis for...
Read more >
Dotenv - npm
Loads environment variables from .env file. Latest version: 16.0.3, last published: 3 months ago. Start using dotenv in your project by ...
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