在 Angular 6.0 之前,我已经创建了一些示意图。schematic 'my-schematic' not found in collection @schematics/angular
当我尝试在托管应用程序(Angular 6)上生成一些代码时,我在 Angular 5.x 中执行的相同步骤现在总是会导致错误?。
我的设置(全局 Angular 的东西):
Angular CLI: 6.0.0
Node: 8.11.1
OS: win32 x64
@angular-devkit/{architect, core, schematics} 0.6.0
@schematics/angular 0.6.0
rxjs 6.1.0
typescript 2.7.2
我的步骤:
- 冉
schematics schematic --name=my-first-schematics
。因此,它创建了一个新的原理图项目,其中包含三个示例模式。然后我导航到那个新文件夹cd my-first-schematics
。 - 冉
npm run build
。它构建没有错误。 - 冉
schematics .:my-first-schematics
。结果:"my-first-schematics" not found in collection "."
我在一些博客中看到他们执行此步骤没有问题的错误。我从来没有运行过这个命令,我不确定它实际上做了什么,所以我会假设这个命令毕竟不是必需的。 - 跑
npm link
,以便我可以在新项目中使用这个新的原理图集合。 - 在另一个提示窗口中,我创建了一个新应用程序:
ng new schematics-consumer
,然后在 npm 安装后,cd schematics-consumer
. - Ran
npm link my-first-schematics
所以我现在可以访问该原理图库。 - 我导航到那是
src/app
我要生成文件的地方。 - 冉
ng g my-schematic -c my-first-schematics
。导致错误Schematic "my-schematic" not found in collection "@schematics/angular"
。我指定了一个集合。为什么它没有看到我的新集合,并且仍然认为每个原理图都在@schematics/angular
?
所以,我不能用原理图生成任何东西。我没有修改schematics schematic name=my-first-schematics
.
是否有一套新的命令、程序等来创建我们自己的自定义原理图?我错过了哪些步骤?我还需要安装什么?如有必要,我会提供更多信息。
目前,还没有关于原理图的新指南或博客,因为 6.0 只有几周的历史,所以我假设旧方法应该仍然有效。