首页 > 解决方案 > 将 NG-Zorro 从 V8 升级到 V9 给出:“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 的导入?这有什么解决方法吗?

标签: angulartypescriptangular-schematicsng-zorro-antd

解决方案


有同样的错误,删除 node_modules 并重新安装后一切都消失了。


推荐阅读