Skip to content

NODE_ENV not inherited from .env file when running in a different mode #3983

Closed
@RickMeijer

Description

@RickMeijer

Version

3.7.0

Reproduction link

https://github.com/RickMeijer/bugreport-vuecli-environment

Environment info

  System:
    OS: macOS Mojave 10.14.4
    CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
  Binaries:
    Node: 10.13.0 - ~/.nvm/versions/node/v10.13.0/bin/node
    Yarn: 1.15.2 - /usr/local/bin/yarn
    npm: 6.9.0 - ~/.nvm/versions/node/v10.13.0/bin/npm
  Browsers:
    Chrome: 74.0.3729.131
    Firefox: 66.0.3
    Safari: 12.1
  npmGlobalPackages:
    @vue/cli: 3.7.0

Steps to reproduce

Either:

  • Clone project
  • npm run build
  • npm run build -- --mode=foo

Or:

  • Create new project
  • Create .env
  • In the .env file, set NODE_ENV to production
  • Create empty .env.foo
  • Run npm run build -- --mode=foo

What is expected?

NODE_ENV should be 'production'

According to the docs; all environments load the .env file. That should mean it also inherits the variables set therin.

What is actually happening?

NODE_ENV is 'development'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions