6

我使用以下命令安装 ngrx/store:

ng add @ngrx/store 

然后我想添加商店

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

得到以下错误:

发生未处理的异常:集合“@schematics/angular”中未找到原理图“存储”。有关详细信息,请参阅“xxx\angular-errors.log”。

4

3 回答 3

10

因为ngrx不是直接的角度原理图。Ngrx 是一个外部库,它支持向您的 Angular 项目添加文件或创建文件

您假设从ngrx原理图json文件生成存储文件,为此您应该运行如下命令

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

如果上述命令失败,您需要运行此命令

npm i @ngrx/schematics -D

您可以在此处找到其用法的详细文档:@ngrx/schematics

于 2020-07-04T07:53:03.163 回答
6

这是安装的最后一步。

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

ng add @ngrx/schematics@latest

这将以这种方式更新您的angular.json文件

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

现在您可以重新运行以前的原理图

例如:

ng generate store admin/Admin -m admin.module.ts
于 2021-01-22T21:12:30.917 回答
1

我遇到了完全相同的问题。安装@ngrx/schematics为我解决了它:

npm install @ngrx/schematics
于 2020-08-13T23:18:51.400 回答