[英]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:运行
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)
This also happens in a brand new Angular 8 project.这也发生在一个全新的 Angular 8 项目中。 The upgrade to Angular 9 works fine but only the NG-Zorro update fails.
升级到 Angular 9 工作正常,但只有 NG-Zorro 更新失败。
These are the contents of the calendar-input-rule.js
file from the error:这些是来自错误的
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
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?我看到有人说这可能是由于循环依赖,但应用程序运行正常,所以错误可能来自 NG-Zorro 的导入? Are there any workarounds this?
这有什么解决方法吗?
Had the same error, after deleting node_modules and re-install everything is was gone.有同样的错误,删除 node_modules 并重新安装后一切都消失了。
I've posted this issue on their Github repo and they provided a workaround for it.我已经在他们的 Github repo上发布了这个问题,他们提供了一个解决方法。 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:我们所要做的就是安装旧版本的
@angular/cdk
(即使我们不直接使用它),直到他们发布补丁:
npm i @angular/cdk@9.2.1 --save
We removed @angular/cdk
from package.json after the update.更新后,我们从 package.json 中删除了
@angular/cdk
。 I don't know if it will affect something in the future.不知道以后会不会有什么影响。 So far so good
到目前为止,一切都很好
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.