简体   繁体   中英

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

After running ng update ng-zorro-antd we get:

[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)

This also happens in a brand new Angular 8 project. The upgrade to Angular 9 works fine but only the NG-Zorro update fails.

These are the contents of the calendar-input-rule.js file from the error:

"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

I saw people saying that it might be due to circular dependencies but the app is working fine, so the error might be from the NG-Zorro's imports? Are there any workarounds this?

Had the same error, after deleting node_modules and re-install everything is was gone.

I've posted this issue on their Github repo and they provided a workaround for it. All we had to do is to install an older version of @angular/cdk (even if we don't use it directly) until they release a patch:

npm i @angular/cdk@9.2.1 --save

We removed @angular/cdk from package.json after the update. I don't know if it will affect something in the future. So far so good

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM