文章内容

2023/5/18 15:43:22,作 者: 黄兵

Appears in the NgModule.imports of SitesModule, but could not be resolved to an NgModule class.

在 Angular 中使用 WYSIWYG 编辑器的时候,在 @NgModule 中导入了 angular-editor 包,代码如下:

import { HttpClientModule} from '@angular/common/http';
import { AngularEditorModule } from '@kolkov/angular-editor';
@NgModule({
imports: [ HttpClientModule, AngularEditorModule ]
})

但是还是报错:

Appears in the NgModule.imports of SitesModule, but could not be resolved to an NgModule class.

出现问题的原因:

你的模块尚未被 Angular 服务器加载,在 Node 中重新运行 ng serve 命令,以便重新启动服务器,使服务器加载你刚刚在 @NgModule app.module.ts 中添加的模块。

解决方案:

重新启动 IDE,之后开始重新编译。

扩展阅读:

ng serve 是 Angular CLI(命令行界面)提供的一个命令,用于启动开发服务器并在本地环境中运行 Angular 应用程序。通过运行 ng serve 命令,Angular CLI 会编译你的应用程序并启动一个开发服务器,用于在浏览器中实时预览和调试应用程序。该命令还会监视文件的更改,并在进行更改时重新编译和刷新应用程序,以便开发过程中的实时更新。


参考资料:

1、error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class


其它相关推荐:

1、Angular 调试表单验证

2、Cannot find module '@angular-devkit/core'

3、Angular - “has no exported member 'Observable'”

4、Angular组件核心特性:输入/输出

5、Angular-mock之使用$httpBackend服务测试$http


黄兵个人博客原创。

转载请注明出处:黄兵个人博客 - Appears in the NgModule.imports of SitesModule, but could not be resolved to an NgModule class.

分享到:

发表评论

评论列表