加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

无法确定组件角度的模块5

发布时间:2020-12-17 07:31:05 所属栏目:安全 来源:网络整理
导读:当我使用“ng build –prod”构建Angular应用程序时,我遇到了以下错误.当我使用Angular 4构建并且使用Angular 5获得错误时,这是??有效的.使用Angular 5“ng serve”工作正常. ERROR in Error: Cannot determine the module for class TimeAgoPipe in mypath/
当我使用“ng build –prod”构建Angular应用程序时,我遇到了以下错误.当我使用Angular 4构建并且使用Angular 5获得错误时,这是??有效的.使用Angular 5“ng serve”工作正常.

ERROR in Error: Cannot determine the module for class TimeAgoPipe in mypath/node_modules/time-ago-pipe/time-ago-pipe.ts! Add TimeAgoPipe to the NgModule to fix it.

获取https://www.npmjs.com/package/time-ago-pipe的错误

有解决方案?

Angular 5和特定角度cli 1.5默认提前编译打开它需要知道它在项目文件夹中找到的所有组件/管道等的模块,如果你有一些未在任何模块中声明的组件它将抛出错误.

您可以在某个模块中声明TimeAgoPipe:

@NgModule({
  declarations: [TimeAgoPipe,...]
})
export class AppModule {}// for example can be any other used module

或者尝试在没有提前编译的情况下运行构建,结果代码将运行得更慢

ng build --prod --aot=false

第三种方法,如果你根本不使用那个管道,你可以将它添加到tsconfig.json中的排除文件

{
  ...
  "exclude": [ "path/to/unused/component.ts",... ]
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读