简体   繁体   English

角度 8 中未发现延迟加载模块错误

[英]Lazy loading module not found error in angular 8

I have copied my existing Angular Project src and package.json file and created new angular project and replaced with my backup src and package.json files.我已经复制了我现有的 Angular 项目 src 和 package.json 文件并创建了新的角度项目并替换为我的备份 src 和 package.json 文件。

After that i run npm install .之后我运行npm install when i try to run the project by ng serve command i am getting this error.当我尝试通过ng serve命令运行项目时出现此错误。

ERROR in ./$$_lazy_route_resource lazy namespace object
Module not found: Error: Can't resolve '/Users/Desktop/Angular/matrix/src/app/ads1/ads1.module.ngfactory.js' in '/Users/Desktop/Angular/matrix/$$_lazy_route_resource'
ERROR in ./$$_lazy_route_resource lazy namespace object
Module not found: Error: Can't resolve '/Users/Desktop/Angular/matrix/src/app/ads2/ads2.module.ngfactory.js' in '/Users/Desktop/Angular/matrix/$$_lazy_route_resource'
ERROR in ./$$_lazy_route_resource lazy namespace object
Module not found: Error: Can't resolve '/Users/Desktop/Angular/matrix/src/app/ads3/ads3.module.ngfactory.js' in '/Users/Desktop/Angular/matrix/$$_lazy_route_resource'
ERROR in ./$$_lazy_route_resource lazy namespace object
Module not found: Error: Can't resolve '/Users/Desktop/Angular/matrix/src/app/banner/banner.module.ngfactory.js' in '/Users/Desktop/A

是的,发现问题在于角度版本不匹配。

You need to add paths to your lazy loaded modules to "files" in tsconig.aot.json:您需要将延迟加载模块的路径添加到 tsconig.aot.json 中的“文件”:

...
"files" [
   ...
   "./ads1/ads1.module.ts",
   etc
   ...
],

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM