Skip to content

vue-cli-service serve does not set process.env.NODE_ENV, or any environmental variables. "process is not defined". #1128

@DonHartman

Description

@DonHartman

Version

2.9.3

Reproduction link

https://github.com/DonHartman/vue-bug

Steps to reproduce

Clone the linked repo. (or Create a .env file for a new vue project in accordance with https://github.com/vuejs/vue-cli/blob/dev/docs/env.md, and give VUE_APP_TEST a value, then use it in code.)

Serve the project with "npm run serve" (I used powershell, if it makes a difference).

View the served app in a browser with dev tools open, I've included a "debugger;" line above the issue.

What is expected?

According to https://github.com/vuejs/vue-cli/blob/dev/docs/env.md , process.env.VUE_APP_TEST should have the "sample" value .

What is actually happening?

The code that accesses "process" throws the error "process is not defined".


The github repo linked has the fully initialized project (the first commit is auto-generated by vue-cli, the second is my minimal changes to recreate the issue). It can likely be reproduced with much less code, but I wanted to emphasize that it is a problem out-of-the-box with vue-cli, so I only made minimal changes to the pre-made project instead of a minimal project.

These are the settings I used to create it:
Run "vue create "
Choose manual settings
Typescript, Router, Vuex, Linkter / Formatter
yes, class style components
yes, babel polyfills
TSLint
Lint on save
In dedicated config files

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