角度打字稿库错误

时间:2021-05-01 05:34:31

标签: angular typescript

我最近将项目从 angular 9 升级到 11,

在我的桌面上运行良好。 当我将项目从 repo 拉到我的笔记本电脑(与版本 9 一起使用)时,我在尝试编译时不断收到以下错误。我将全局 Angular CLI 更新为 11.2.11(项目在 11.2.2 上)和 Typescript 到 4.1.5。

这是错误:

Your global Angular CLI version (11.2.11) is greater than your local version (11.2.2). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false".
Building Angular Package
******************************************************************************   
It is not recommended to publish Ivy libraries to NPM repositories.
Read more here: https://v9.angular.io/guide/ivy#maintaining-library-compatibility
******************************************************************************   

------------------------------------------------------------------------------
Building entry point 'nine-gold-lib'
------------------------------------------------------------------------------
⠙ Compiling TypeScript sources through NGCCompiling @angular/core : es2015 as esm2015
Error: Error on worker #1: TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator))
    at __read (C:\Users\fwitk\Documents\GitHub\ninegoldplatform\node_modules\tslib\tslib.js:174:50)
    at Object.__spread (C:\Users\fwitk\Documents\GitHub\ninegoldplatform\node_modules\tslib\tslib.js:193:28)
    at Renderer.renderAdjacentStatements (C:\Users\fwitk\Documents\GitHub\ninegoldplatform\node_modules\@angular\compiler-cli\ngcc\src\rendering\renderer.js:159:63)
    at C:\Users\fwitk\Documents\GitHub\ninegoldplatform\node_modules\@angular\compiler-cli\ngcc\src\rendering\renderer.js:80:52
    at Array.forEach (<anonymous>)
    at Renderer.renderFile (C:\Users\fwitk\Documents\GitHub\ninegoldplatform\node_modules\@angular\compiler-cli\ngcc\src\rendering\renderer.js:76:46)       
    at C:\Users\fwitk\Documents\GitHub\ninegoldplatform\node_modules\@angular\compiler-cli\ngcc\src\rendering\renderer.js:53:84
    at Array.forEach (<anonymous>)
    at Renderer.renderProgram (C:\Users\fwitk\Documents\GitHub\ninegoldplatform\node_modules\@angular\compiler-cli\ngcc\src\rendering\renderer.js:48:54)    
    at Transformer.transform (C:\Users\fwitk\Documents\GitHub\ninegoldplatform\node_modules\@angular\compiler-cli\ngcc\src\packages\transformer.js:84:42)   
    at ClusterMaster.onWorkerMessage (C:\Users\fwitk\Documents\GitHub\ninegoldplatform\node_modules\@angular\compiler-cli\ngcc\src\execution\cluster\master.js:195:27)
    at C:\Users\fwitk\Documents\GitHub\ninegoldplatform\node_modules\@angular\compiler-cli\ngcc\src\execution\cluster\master.js:55:95
    at ClusterMaster.<anonymous> (C:\Users\fwitk\Documents\GitHub\ninegoldplatform\node_modules\@angular\compiler-cli\ngcc\src\execution\cluster\master.js:293:57)
    at step (C:\Users\fwitk\Documents\GitHub\ninegoldplatform\node_modules\tslib\tslib.js:143:27)
    at Object.next (C:\Users\fwitk\Documents\GitHub\ninegoldplatform\node_modules\tslib\tslib.js:124:57)
    at C:\Users\fwitk\Documents\GitHub\ninegoldplatform\node_modules\tslib\tslib.js:117:75
    at new Promise (<anonymous>)
    at Object.__awaiter (C:\Users\fwitk\Documents\GitHub\ninegoldplatform\node_modules\tslib\tslib.js:113:16)
    at EventEmitter.<anonymous> (C:\Users\fwitk\Documents\GitHub\ninegoldplatform\node_modules\@angular\compiler-cli\ngcc\src\execution\cluster\master.js:287:32)
    at EventEmitter.emit (events.js:315:20)
× Compiling TypeScript sources through NGC
ERROR: NGCC failed.

1 个答案:

答案 0 :(得分:1)

问题在于 tslib 版本未基于 package.json 更新;手动更新后错误消失。