Angular 9-NGCC因未处理的异常而失败 [英] Angular 9 - NGCC fails with an unhandled exception

查看:218
本文介绍了Angular 9-NGCC因未处理的异常而失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

将依赖关系升级到Angular 9(并执行了必要的代码更改)之后,对应用程序进行构建会引发错误:

Buidling the application after having upgraded dependcies to Angular 9 (and having performed necessary code changes) throws an error:

编译@ angular/animations:es2015 as esm2015编译 @ angular/animations:es2015作为esm2015编译@ angular/core: es2015 as esm2015编译@ angular/core:es2015 as esm2015
编译@ angular/core:es2015作为esm2015
错误:工作人员5上的错误:TypeError:无法读取null属性'fileName'

Compiling @angular/animations : es2015 as esm2015 Compiling @angular/animations : es2015 as esm2015 Compiling @angular/core : es2015 as esm2015 Compiling @angular/core : es2015 as esm2015
Compiling @angular/core : es2015 as esm2015
Error: Error on worker #5: TypeError: Cannot read property 'fileName' of null

然后继续抛出以下错误:

It then goes on to throw the below error:

编译@ angular/core:es2015 as esm2015编译 @ angular/compiler/testing:es2015作为esm2015编译 @ angular/core:es2015作为esm2015
错误:试图用ngcc回写node_modules/@angular/core/core.d.ts.__ivy_ngcc_bak 文件,但它已经存在,因此无法写入或备份, node_modules/@angular/core/core.d.ts.

Compiling @angular/core : es2015 as esm2015 Compiling @angular/compiler/testing : es2015 as esm2015 Compiling @angular/core : es2015 as esm2015
Error: Tried to write node_modules/@angular/core/core.d.ts.__ivy_ngcc_bak with an ngcc back up file but it already exists so not writing, nor backing up, node_modules/@angular/core/core.d.ts.

此错误可能是因为两个或多个入口点重叠,并且ngcc被要求多次处理某些文件.
您应该检查此程序包中的其他入口点,并设置一个配置以忽略不使用的任何入口.

This error may be because two or more entry-points overlap and ngcc has been asked to process some files more than once.
You should check other entry-points in this package and set up a config to ignore any that you are not using.

编译@ angular/core:es2015 as esm2015未处理的异常 发生:NGCC失败.

Compiling @angular/core : es2015 as esm2015 An unhandled exception occurred: NGCC failed.

推荐答案

我和我的同事开发人员在本地计算机上遇到此问题(NGCC失败).

This problem (NGCC failed) was encountered by me and my colleague developer on our localhost machines.

重要的是要指出开发和生产机器运行良好.

It would be important to remark that the dev and prod machines were running well.

为了解决此问题,我们执行了以下步骤:

In order to solve this problem we've followed the next steps:

  1. tsconfig.json 中的 angularCompilerOptions 中已设置(" enableIvy ":false)
  2. 将nodeJS更新到最新版本:(执行 node -v 返回v14.3.0)
  3. 已删除 node_modules 文件夹:(在Windows上执行"rm.\ node_modules \" ,请确保已成功删除该文件)
  4. 已安装软件包:(执行 npm i )
  5. 此处已​​准备好构建项目.现在,它可以正确构建并运行.
  1. in tsconfig.json, in angularCompilerOptions have set ("enableIvy": false)
  2. updated the nodeJS to the last version: (executing node -v returned v14.3.0)
  3. have deleted the node_modules folder: (executing "rm .\node_modules\" [on windows], make sure it has been deleted successfully)
  4. have installed the packages: (executing npm i )
  5. here the project is ready to be built. It builds and runs without errors now.

希望这样对您和其他人有帮助.

I wish this helps you and other people in situations like this.

这篇关于Angular 9-NGCC因未处理的异常而失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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