How to set environment via `ng serve` in angular 6

  • A+

I am trying to update my angular 5.2 app to angular 6. I successfully followed instructions in angular update guide (including the update of angular-cli to v6), and now I am trying to serve the app via

ng serve --env=local 

But this gives me error:

Unknown option: '--env'

I use multiple environments (dev/local/prod), and this is the way it was working in 5.2. How can I set the environment now in angular 6?

You need to use the new configuration option

ng serve --configuration=local 


ng serve -c local 

If you look at your angular.json file, you'll see that you have finer control over settings for each configuration (aot, optimizer, environment files,...)

"configurations": {         "production": {           "optimization": true,           "outputHashing": "all",           "sourceMap": false,           "extractCss": true,           "namedChunks": false,           "aot": true,           "extractLicenses": true,           "vendorChunk": false,           "buildOptimizer": true,           "fileReplacements": [             {               "replace": "src/environments/environment.ts",               "with": "src/environments/"             }           ]         }       } 

You can get more info here for managing environment specific configurations


:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: