Angular 15 CLI does not create environments folder when creating an angular project via ng new

See Angular – Configure Environment Specific Defaults

EDIT:- As predicted, GitHub Issue

After the release of Angular CLI 15.1, a generation schematic will be available to add environment files for all existing build configurations within a project.
Example usage:

ng g environments


To manually create:

If you want to recreate environments, follow these steps:

  • Create environments directory

  • Create your custom environments

    • environment.ts
    • environment.prod.ts
    • environment.staging.ts etc.
  • Update your angular.json or project.json to do fileReplacements where the paths are from project root to the environment file for replace and with:

  "configurations": {
       "production": {
          ...
          "fileReplacements": [
            {
              "replace": "apps/some-app/src/environments/environment.ts",
              "with": "apps/some-app/src/environments/environment.prod.ts"
            }
          ],
        },
        "development": {
          ...
        }
      },
      "defaultConfiguration": "production"
    },

Leave a Comment