找不到模块:错误:无法解析'./$$_gendir/app/app.app.module.ngfactory' [英] Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory'

查看:116
本文介绍了找不到模块:错误:无法解析'./$$_gendir/app/app.app.module.ngfactory'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级我的angular-cli后,出现以下错误

I get this below error after upgrading my angular-cli

ERROR in Template parse errors:
Can't bind to 'index' since it isn't a known property of 'tag'. ("own)="handleKeydown($event, item)"
             (onTagEdited)="onTagEdited.emit(item)"
             [ERROR ->][index]="i"
             [attr.tabindex]="readonly ? -1 : 0"
             [class.readonly]="readonly""): TagInputComponent@16:13

ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'D:\xxxx\yyyy\eeeee\eeee\src'
 @ ./src/main.ts 5:0-74
 @ multi ./src/main.ts

当我运行ng build --prod时会发生此错误,而当我运行ng build没有任何参数时可以正常工作

This error happens when i run ng build --prod and works fine when i run ng build without any parameters,

推荐答案

当您在angular 2中运行ng build时,最新的angular-cli将自动使用--aot参数运行(提前编译),因此它试图优化您的代码.您所使用的软件包尚不兼容以进行优化.因此,您需要更新软件包.最有可能在您的app.module.ts

When you run the ng build in angular 2, latest angular-cli automatically runs with --aot parameter (ahead of time compilation), so it is trying to optimize your code. You are having a package that is not yet compatible for optimizing. So you need update to your packages. Most probably the packages that has **forRoot()** in your app.module.ts

我建议更新所有软件包.

更新软件包的简便方法是使用如下所示的ncu npm软件包,我从

Easy way to update your package is to use ncu npm package as in below, which i got it from How do I correctly upgrade angular 2 (npm) to the latest version?

安装

npm install -g npm-check-updates

用法

ncu用于显示

ncu -u用于重写package.json

ncu -u for re-writing your package.json

并运行npm install来更新您的软件包

and run npm install to update your packages

如果上述方法不起作用,则可能需要更新代码以符合AOT要求.请参考下面的网址,以对您的代码进行更改. https://medium.com/@isaacplmann/getting您的Angular-2-library-ready-for-aot-90d1347bcad

If above did not work, you might need to update your code for aot compliance. Refer this url below to make changes in your code. https://medium.com/@isaacplmann/getting-your-angular-2-library-ready-for-aot-90d1347bcad

这篇关于找不到模块:错误:无法解析'./$$_gendir/app/app.app.module.ngfactory'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆