Skip to content

ng serve ignoring the env parameter and loads another envionment file #7793

@poblouin

Description

@poblouin

Bug Report or Feature Request (mark with an x)

- [x ] bug report -> please search issues before submitting
- [ ] feature request

Versions.

@angular/cli: 1.4.3
node: 8.5.0
os: linux x64
@angular/animations: 4.4.3
@angular/cdk: 2.0.0-beta.11
@angular/common: 4.4.3
@angular/compiler: 4.4.3
@angular/core: 4.4.3
@angular/forms: 4.4.3
@angular/http: 4.4.3
@angular/material: 2.0.0-beta.11
@angular/platform-browser: 4.4.3
@angular/platform-browser-dynamic: 4.4.3
@angular/router: 4.4.3
@angular/cli: 1.4.3
@angular/compiler-cli: 4.4.3
@angular/language-service: 4.4.3
typescript: 2.3.4

Repro steps.

Hello, I'm starting to get a little crazy with this, I looked at the issues here, tried multiple things, not sure what is wrong. I can't make ng serve to use a specific environment file. I tried multiple syntax found in the doc and the issues, I'm now using "ng serve -e dev -dev", the app build fine, but my settings in environment.ts are not loaded, it's the settings from environment.prod.ts that are loaded.

In my angular-cli.json

  "environmentSource": "environments/environment.ts",
  "environments": {
    "dev": "environments/environment.ts",
    "beta": "environments/environment.beta.ts",
    "prod": "environments/environment.prod.ts"
  }

The file structure:

screenshot from 2017-09-22 15-58-38

And the content of environment.ts

export const environment = {
  production: false,
  apiUrl: 'http://localhost:8000/api/v1'
};

In environment.beta.ts and environment.prod.ts production = true and apiUrl = ''

And then, when I try to logging in my app, it does not working because the url to my REST API is not valid. Instead of the localhost:8000 specified in my file, it tries to call the API on localhost:4200 (which is the port used by my angular app).

Someone has any idea what I'm doing wrong here?

The log given by the failure.

None

Desired functionality.

Help to make this work..

Mention any other details that might be useful.

None

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions