【问题标题】:ERROR: Dependency @types/html2canvas must be explicitly allowed using the "allowedNonPeerDependencies" option错误:必须使用“allowedNonPeerDependencies”选项明确允许依赖关系@types/html2canvas
【发布时间】:2021-06-08 23:21:56
【问题描述】:

我在我的 Angular 库项目中安装了 html2canvas,当我在生产模式下编译时(运行 ng build --prod 命令),我收到以下错误:

错误:依赖@types/html2canvas 必须明确允许使用 “allowedNonPeerDependencies”选项。

我该如何解决?

【问题讨论】:

    标签: javascript angular typescript npm angular-cli


    【解决方案1】:

    您可以在package.json 中将库添加到您的peerDependencies我强烈建议使用peerDependencies 策略,因为它会明确向其他人公开您的库依赖于其他库

    {
        ...
        "scripts": {...},
        "peerDependencies": {
            ...
            "@types/html2canvas": "0.0.36",
            ...
        },
    }
    

    或者您可以使用 ng-package.json 上的选项:

    {
        ...
        "lib": {
            "entryFile": "src/public-api.ts"
        },
        "allowedNonPeerDependencies": [
            "@type/html2canvas"
        ]
        ...
    }
    

    【讨论】:

      猜你喜欢
      • 2021-01-25
      • 2020-10-19
      • 1970-01-01
      • 2019-10-09
      • 2016-01-28
      • 2018-01-02
      • 1970-01-01
      • 2018-10-22
      • 1970-01-01
      相关资源
      最近更新 更多