8

I install ngrx/store with the following command :

ng add @ngrx/store 

then I want to add store

ng generate store auth/Auth --module auth.module.ts

get the following error :

An unhandled exception occurred: Schematic "store" not found in collection "@schematics/angular". See "xxx\angular-errors.log" for further details.

3 Answers3

13

Because ngrx is not an direct angular schematics. Ngrx is a external library which provide support to add files or create files to your angular project

Your are suppose to generate store file from the ngrx schematics json file, to do that you should run command like below

ng generate @ngrx/schematics:store State --root --module app.module.ts

If the above command fails you need to run this command

npm i @ngrx/schematics -D

You can find the detail documentation of its usage here: @ngrx/schematics

Mauricio Gracia Gutierrez
  • 10,288
  • 6
  • 68
  • 99
sunilbaba
  • 441
  • 2
  • 9
  • I liked your answer better because doesn't envolve changing the "defaultSchematic". Thanks for sharing. – Igor Jul 06 '20 at 03:04
10

This the last step of the installation.

https://ngrx.io/guide/schematics/install

ng add @ngrx/schematics@latest

This will update your angular.json file this way

  "cli": {
    "defaultCollection": "@ngrx/schematics"
  }

Now you may re-run the previous schematics

For ex:

ng generate store admin/Admin -m admin.module.ts
3

I faced the exact same problem. Installing @ngrx/schematics solved it for me:

npm install @ngrx/schematics
s-gbz
  • 402
  • 8
  • 11
stefanvz
  • 55
  • 4