angular2项目,之前运行还没问题,隔了几天再次运行就有这个问题了。
node_modules/ng-zorro-antd/carousel/carousel.module.d.ts:1:22 - error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class.
这个错误出现了好多,就像截图里显示的,已经是第五个了。
我删除node_modules.json,又重新cnpm,但之后还是这个问题
百度后得到了这两种结果:
1、app.module.ts里引入错了
XXXComponent应该引入到declarations里,却错误的引入到 imports里
2、通过根据文档选择退出Ivy来修复此问题。
github里有人给出的临时解决方案
My temporary solution was to add:
"enableIvy": false,
"angularCompilerOptions": {
"fullTemplateTypeCheck": true,
"enableIvy": false, <---
"strictInjectionParameters": true
}
from my file tsconfig.json
https://github.com/angular/angular/issues/35255
我看有的人是在tsconfig.json
里加这句,也有人在tsconfig.app.json
里加这句。我是在tsconfig.app.json
里加的,反正成功了,也就没细究区别