尝试用一个ngcc备份文件覆盖 @angular/cdk/stepper/step-header.d.ts.__ivy_ngcc_bak 文件,这是不允许的。

19

使用ng update命令升级@angular/core@angular/material后,运行ngcc命令会出现以下错误:

使用的命令:

ngcc --properties es2015 browser module main --first-only --create-ivy-entry-points

错误信息:

> Compiling @angular/cdk/stepper : es2015 as esm2015
> Compiling @angular/cdk/drag-drop : es2015 as esm2015
> Error: Error on worker #3: Error: Tried to overwrite node_modules/@angular/cdk/stepper/step-header.d.ts.__ivy_ngcc_bak with an ngcc back up file, which is disallowed.
>     at NewEntryPointFileWriter.InPlaceFileWriter.writeFileAndBackup (node_modules/@angular/compiler-cli/ngcc/src/writing/in_place_file_writer.js:37:23)
>     at NewEntryPointFileWriter.writeFile (node_modules/@angular/compiler-cli/ngcc/src/writing/new_entry_point_file_writer.js:64:53)
>     at node_modules/@angular/compiler-cli/ngcc/src/writing/new_entry_point_file_writer.js:46:69
>     at Array.forEach (<anonymous>)
>     at NewEntryPointFileWriter.writeBundle (node_modules/@angular/compiler-cli/ngcc/src/writing/new_entry_point_file_writer.js:46:30)
>     at ClusterWorker.compile (node_modules/@angular/compiler-cli/ngcc/src/main.js:173:32)
>     at Worker.<anonymous> (node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/worker.js:44:42)
>     at Worker.emit (events.js:321:20)
>     at process.<anonymous> (internal/cluster/worker.js:32:12)
>     at process.emit (events.js:321:20)
>     at ClusterMaster.onWorkerMessage (node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/master.js:158:27)
>     at node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/master.js:46:95
>     at ClusterMaster.<anonymous> (node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/master.js:238:57)
>     at step (node_modules/tslib/tslib.js:136:27)
>     at Object.next (node_modules/tslib/tslib.js:117:57)
>     at node_modules/tslib/tslib.js:110:75
>     at new Promise (<anonymous>)
>     at Object.__awaiter (node_modules/tslib/tslib.js:106:16)
>     at EventEmitter.<anonymous> (node_modules/@angular/compiler-cli/ngcc/src/execution/cluster/master.js:232:32)
>     at EventEmitter.emit (events.js:321:20)
4个回答

19

升级到angular 9后,请确保清理您的工作区并重新安装所有包/依赖项。 这实际上解决了我的大部分错误。

通过删除node_modules文件夹,package_lock.json文件,并使用npm install重新安装所有软件包来清理工作区可以解决大多数问题。

  • 删除node_modules文件夹
  • 删除package_lock.json文件
  • 在删除后使用npm install重新安装软件包

13
啊,那个古老的“烧毁一切,之后就像什么都没发生过一样继续”的技巧。几乎每次都有效。 - Stefan Falk
1
删除 node_modules 应该就足够了(只要您没有手动更改 package_lock.json)。 - Segev -CJ- Shmueli

7

关闭 enableIvy 对我有帮助。

tsconfig 文件中,找到 angularCompilerOptions

添加 "enableIvy": false


根据 https://github.com/NG-ZORRO/ng-zorro-antd/issues/4236,需要使用 ng-zorro-antd v9.0.2+。 - JRA_TLL
这将编译,但会呈现一个带有错误信息的空白页面 - 找不到编译器。 - Sanjay Achar
我也试过了,有效! - Love to Code

0
在我的情况下,我有一个使用npm link命令在消费者应用程序中使用的Angular 11库。
当我在消费者应用程序中运行npm start时,我遇到了错误。 对我来说,解决方法是在库的tsconfig.json中进行更改(之前为“false”)。
angularCompilerOptions": 
{
    "enableIvy": true 
}

有趣的是,这个修复与@Ahmed El-Araby上面提到的Angular 9的修复相反,可能是因为在Angular 11中,默认启用了Ivy。

0
在/dist目录中删除所有文件 *.__ivy_ngcc_bak 和目录ivy_ngcc,然后再次运行ng build。这对我来说运行良好。

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接