angular - 更新到 9.2.4 后 Angular/material 崩溃
问题描述
今天我已经将 Angular/material 从 9.2.0-next 更新到 9.2.4,在 ng serve 之后我得到了这个:
platform.js:78 Uncaught TypeError: Class constructor Platform cannot be invoked without 'new'
at Module../node_modules/@angular/cdk/__ivy_ngcc__/fesm2015/platform.js (platform.js:78)
at __webpack_require__ (bootstrap:84)
at Module../node_modules/@angular/cdk/__ivy_ngcc__/fesm2015/a11y.js (a11y.js:1)
at __webpack_require__ (bootstrap:84)
at Module../node_modules/@angular/material/__ivy_ngcc__/fesm2015/core.js (core.js:1)
at __webpack_require__ (bootstrap:84)
at Module../node_modules/@angular/material/__ivy_ngcc__/fesm2015/icon.js (icon.js:1)
at __webpack_require__ (bootstrap:84)
at Module../src/app/home/home.component.ts (home.component.ts:1)
at __webpack_require__ (bootstrap:84)
试图删除 node_modules 文件夹并重新安装它,我该怎么办?
ng --version
Angular CLI: 9.1.8 Node: 12.8.1 OS: win32 x64
Angular: 9.1.11 ... animations, common, compiler, compiler-cli, core, forms ... language-service, localize, platform-browser ... platform-browser-dynamic, router, service-worker Ivy Workspace: Yes
Package Version
------------------------------------------------------------
@angular-devkit/architect 0.901.8
@angular-devkit/build-angular 0.901.8
@angular-devkit/build-optimizer 0.901.8
@angular-devkit/build-webpack 0.901.8
@angular-devkit/core 9.1.8
@angular-devkit/schematics 9.1.8
@angular/cdk 10.0.0-rc.1-sha-a3dabc93d
@angular/cli 9.1.8
@angular/material 9.2.4
@angular/material-moment-adapter 9.2.4
@ngtools/webpack 9.1.8
@schematics/angular 9.1.8
@schematics/update 0.901.8
rxjs 6.5.5
typescript 3.7.5
webpack 4.42.0
ts.config
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"downlevelIteration": true,
"experimentalDecorators": true,
"module": "esnext",
"moduleResolution": "node",
"importHelpers": true,
"target": "es2015",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
},
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"strictInjectionParameters": true,
"allowSyntheticDefaultImports": true
}
}
ts.config.app
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": []
},
"files": [
"src/main.ts",
"src/polyfills.ts"
],
"include": [
"src/**/*.d.ts"
],
"exclude": [
"src/test.ts",
"src/**/*.spec.ts"
]
}
解决方案
通过将@angular/cdk更新到 9.2.4也解决了(ot 被卡在 github:angular/cdk-builds),然后重新安装了所有内容npm i
推荐阅读
- mongodb - MongoDB在并发更新单个文档时分配大量内存
- elasticsearch - 我正在寻找创建每日指数的流程。可以每天生成日志报告
- c# - Application_DispatcherUnhandledException 问题
- oracle - DBMS_OUTPUT.PUT 不打印数据,我已经尝试了我在论坛中找到的所有解决方案
- pdf - 自动打开使用 PDFBox 创建的 PDF 大纲
- python - Python:如何重塑具有各种维度的多维数组?
- python - 来自 pandas 数据框的列表生成器
- spring - 带有 Spring Security 的 SpringBoot 2 执行器
- python - 从列表中添加和检索项目
- visual-studio - Reporting Services tablix 不允许我冻结列标题和行