Search code examples
angular

A collection and schematic is required during execution error when executing "ng generate environments"


I'm using Angular 15 and Node version 18.12.1.

I created a new application in Visual Studio Code but learned that Angular no longer provides the environment files that were for test and production purposes.

I want these environment files back so I followed the instructions from Angular's site.

https://angular.io/guide/build

From PowerShell I entered "ng generate environments" but I get the following error message:

"Error: A collection and schematic is required during execution"

I need help figuring out how to get this working.

I followed the directions on Angular's site and that didn't work.

I also tried updating my version of Node just to be sure it was up-to-date.

None of these resolved my issue to create the environment files.


Solution

  • There was a Github issue for this: https://github.com/angular/angular-cli/issues/24381

    Also check this related post: Angular 15 CLI does not create environments folder when creating an angular project via ng new

    EDIT: Found another article about this, apparantly in Angular version 15.1 it should work again: https://dev.to/this-is-angular/angular-15-what-happened-to-environmentts-koh

    So check your current version:

    ng version
    

    Do update (if it's 15.0.X):

    ng update
    

    Then this should work again:

    ng generate environments