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

查看:36
本文介绍了找不到模块:错误:无法解析“./$$_gendir/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 包,这是我从 如何将 angular 2 (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 标准.请参阅下面的此 url 以更改您的代码.https://medium.com/@isaacplmann/getting-your-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.module.ngfactory"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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