簡體   English   中英

將 NG-Zorro 從 V8 升級到 V9 給出:“Class extends value undefined is not a constructor or null”

[英]Upgrading NG-Zorro from V8 to V9 gives: “Class extends value undefined is not a constructor or null”

運行ng update ng-zorro-antd ,我們得到:

[error] TypeError: Class extends value undefined is not a constructor or null
    at Object.<anonymous> (C:\Users\<user name>\Desktop\Work\<project name>\node_modules\ng-zorro-antd\schematics\ng-update\upgrade-rules\checks\calendar-input-rule.js:4:49)

這也發生在一個全新的 Angular 8 項目中。 升級到 Angular 9 工作正常,但只有 NG-Zorro 更新失敗。

這些是來自錯誤的calendar-input-rule.js文件的內容:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const schematics_1 = require("@angular/cdk/schematics");
class CalendarTemplateRule extends schematics_1.MigrationRule {
    constructor() {
        super(...arguments);
        this.ruleEnabled = this.targetVersion === schematics_1.TargetVersion.V9;
    }
    visitTemplate(template) {
        schematics_1.findInputsOnElementWithTag(template.content, 'nzCard', ['nz-calendar'])
            .forEach(offset => {
            this.failures.push({
                filePath: template.filePath,
                position: template.getCharacterAndLineOfPosition(offset),
                message: `Found deprecated input "nzCard" component. Use "nzFullscreen" to instead please.`
            });
        });
    }
}
exports.CalendarTemplateRule = CalendarTemplateRule;
//# sourceMappingURL=calendar-input-rule.js.map

我看到有人說這可能是由於循環依賴,但應用程序運行正常,所以錯誤可能來自 NG-Zorro 的導入? 這有什么解決方法嗎?

有同樣的錯誤,刪除 node_modules 並重新安裝后一切都消失了。

我已經在他們的 Github repo上發布了這個問題,他們提供了一個解決方法。 我們所要做的就是安裝舊版本的@angular/cdk (即使我們不直接使用它),直到他們發布補丁:

npm i @angular/cdk@9.2.1 --save

更新后,我們從 package.json 中刪除了@angular/cdk 不知道以后會不會有什么影響。 到目前為止,一切都很好

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM