【问题标题】:Angular Schematics: Not found : my-schematic error角度示意图:未找到:我的示意图错误
【发布时间】:2019-04-21 06:47:54
【问题描述】:

我构建了一个简单的 Angular Schematics,名为:my-schematics。

我能够将(使用 angular cli)我的原理图添加到某个项目中。

当我运行ng update my-schematics 时出现错误提示: Not found : my-schematic.

我不知道为什么。这是我的collection.json

    "schematics": {
      "update": {
        "description": "Updates version test",
        "factory": "./ng-update/index#update"
      }
    }

【问题讨论】:

    标签: angular angular-schematics


    【解决方案1】:

    在 collection.json 中,您的原理图被命名为“更新”而不是 my-schematics。

    如果你想运行你的原理图,你应该

    ng g update
    

    而不是 ng update my-schematics

    collection.json 在 angular.json 中,您可以为原理图添加默认集合:

    "cli": {
      "defaultCollection": "<path-to-your-collection>/collection.json",
    }
    

    如果你的集合不是默认集合,你应该运行它

    ng g <your-collection>:<your-schematic-name>
    

    查看https://blog.angular.io/schematics-an-introduction-dc1dfbc2a2b2 了解更多关于原理图的信息

    【讨论】:

      【解决方案2】:

      尝试将你的“update”重命名为“ng-update”,你需要定义schema.json

      "schematics": {
        "ng-update": {
          "description": "Updates version test",
          "factory": "./ng-update/index#update",
          "schema": "./ng-update/schema.json" // schema.json to add
        }
      }
      

      【讨论】:

        【解决方案3】:

        问题是你必须先安装你的原理图,所以它会在你的node_modules文件夹下。我在构建它之后通过运行npm install 来做到这一点。

        看看这个博客: https://medium.com/swlh/automate-your-teams-boilerplates-by-building-your-own-schematics-640949001d46?source=friends_link&sk=4b90f9ecc092b598e75c5bbbd6e473a1

        它几乎涵盖了它。

        【讨论】:

          猜你喜欢
          • 2019-08-07
          • 2019-08-23
          • 2018-12-26
          • 2019-11-02
          • 2019-02-14
          • 2019-05-17
          • 2021-11-03
          • 2018-12-07
          • 2020-06-07
          相关资源
          最近更新 更多