Ionic build --prod时报“app.module.ngfactory doesn't exist等” 一些列模糊错误时

2 篇文章 0 订阅
  1. 此时不要盲目确定是ngmodel中哪个子模块出了问题,因为错误描述并没有详细跟踪到具体的错误地点,这里只是一个全局的描述“Can’t resolve './app.module.ngfactory”
  2. 由于是node_module执行过程出的问题,可以用此命令进行查看(build的时候会启动ngc):
    ./node_modules/.bin/ngc
    显示详细描述信息为:

Error: Type TrustUrlPipe in /Users/path to… /ionic/xx/src/pipes/trust-url/trust-url.ts is part of the declarations of 2 modules: AppModule in /Users/path to…/ionic/xx/src/app/app.module.ts
and PipesModule in /Users/path to…/ionic/xx/src/pipes/pipes.module.ts!
Please consider moving TrustUrlPipe in /Users/path to…/ionic/xx/src/pipes/trust-url/trust-url.ts to a higher module that imports AppModule in /Users/path to …/ionic/xx/src/app/app.module.ts and PipesModule in /Users/path to…/ionic/xx/src/pipes/pipes.module.ts.
You can also create a new NgModule that exports and includes TrustUrlPipe in /Users/path
to…/ionic/xx/src/pipes/trust-url/trust-url.ts then import that NgModule
in AppModule in /Users/path to …/ionic/xx/src/app/app.module.ts and
PipesModule in /Users/path to …/ionic/xx/src/pipes/pipes.module.ts.

3.检查provider管道,的确在该目录下重复声明了一次ngModule
4.重新执行build --prod 发现还是会有错误,没有关系,继续跟踪ngc,查看详细错误,逐个解决掉就好了
5.记得加sudo执行build --prod 有些会因为权限问题导致build无法成功。
6.如果一直提示“Can’t resolve ‘./app.module.ngfactory’” ,请查看这里:https://github.com/ionic-team/ionic-app-scripts/issues/1309
解决办法:修改package.json中的@ionic-scripts的版本,更新查看npm的@ionic-scripts版本,再次执行。

如有帮助,无须言谢。
转载说明出处,感谢。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值