Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

545
Visualizações
angular cli change default environment when running ng serve

When I run ng serve it uses default environment as dev. Is there a way to update angular cli to use a different environment file?

Update

Sorry, Should have been more clear in my question. I know we can use --env switch to specify the environment file to use, but was wondering if there is a way to change the default environment file selection when no env is specified. Currently we have environment.local.ts file, I am trying to update angular cli configuration to use environment.local.ts when no environment is specified.

about 4 years ago · Santiago Trujillo
3 Respostas
Responde à pergunta

0

I had the same issue as you, and couldn't find a way to override the default environment variable used when no env arg is passed, but found a workaround that worked for me:

Simply change the file path that is standing for the dev environment in the angular cli configuration file (angular-cli.json):

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

dev is the default environment variable used by Angular CLI if no args are passed, so the local file would be the used one.

about 4 years ago · Santiago Trujillo Relatório

0

For Angular 6+ follow these instructions:

First you will define your environments in your angular.json, create those files, and then you will run via "ng serve --configuration dev"

This document covers the details of the above:

https://theinfogrid.com/tech/developers/angular/environment-variables-angular/

Additionally you will need to define the same in the "serve" section of the JSON...i.e:

"serve": {
 [...]
 "configurations": {
   "production": {
     "browserTarget": "myApp:build:production"
   },
   "debug": {
     "browserTarget": "myApp:build:debug"
   }
 }
about 4 years ago · Santiago Trujillo Relatório

0

Try using the --environment option through the CLI:

ng serve --environment prod will use the environment.prod.ts file.

You can also configure your environments in .angular-cli.json file.

Hope this helps!

about 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda