javascript Angular ng serve产生错误:NGCC失败

3phpmpom  于 2023-10-14  发布在  Java
关注(0)|答案(5)|浏览(204)

在运行ng serve后,我在终端窗口中遇到了一个异常:
编译@angular/core:模块作为esm 5

Error: Error on worker #1: TypeError: Cannot read property 'map' of undefined

下面留言:

An unhandled exception occurred: NGCC failed.

请参阅/tmp/ng-EAdxWj/angular-errors.log了解更多详细信息。
angular-errors.log:

[error] Error: NGCC failed.
    at NgccProcessor.process (/IdeaProjects/app/frontend/node_modules/@ngtools/webpack/src/ngcc_processor.js:76:19)
    at /IdeaProjects/app/frontend/node_modules/@ngtools/webpack/src/angular_compiler_plugin.js:579:31
    at SyncHook.eval [as call] (eval at create (/IdeaProjects/app/frontend/node_modules/tapable/lib/HookCodeFactory.js:19:10), <anonymous>:7:1)
    at SyncHook.lazyCompileHook (/IdeaProjects/app/frontend/node_modules/tapable/lib/Hook.js:154:20)
    at Object.webpack [as webpackFactory] (/IdeaProjects/app/frontend/node_modules/webpack/lib/webpack.js:55:30)
    at createWebpack (/IdeaProjects/app/frontend/node_modules/@angular-devkit/build-webpack/src/webpack-dev-server/index.js:20:36)
    at Object.runWebpackDevServer (/IdeaProjects/app/frontend/node_modules/@angular-devkit/build-webpack/src/webpack-dev-server/index.js:46:12)
    at SwitchMapSubscriber.project (/IdeaProjects/app/frontend/node_modules/@angular-devkit/build-angular/src/dev-server/index.js:191:32)
    at SwitchMapSubscriber._next (/IdeaProjects/app/frontend/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/operators/switchMap.js:49:27)
    at SwitchMapSubscriber.Subscriber.next (/IdeaProjects/app/frontend/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/Subscriber.js:66:18)
    at /IdeaProjects/app/frontend/node_modules/@angular-devkit/build-angular/node_modules/rxjs/internal/util/subscribeToPromise.js:7:24
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
rjjhvcjd

rjjhvcjd1#

只是有同样的问题。
通过在tsconfig.app.json中添加以下内容修复了它:

"angularCompilerOptions": {
    "enableIvy": false
},

希望这有帮助

e5nszbig

e5nszbig2#

我犯了一个错误:

Unknown arguments: use-program-dependencies, useProgramDependencies
An unhandled exception occurred: NGCC failed.
See "C:\...\angular-errors.log" for further details.

我只是更新了angular approach、material和core以及我的项目所需的其他模块,然后更新了npm和typescript包,仅此而已。

ng update @angular/cli @angular/core
npm update @angular/material @angular/cdk
npm install -g typescript@latest
unftdfkk

unftdfkk3#

在我的特殊情况下,在运行npm审计修复后,我的package.json中的@angular-devkit/build-angular被更新为“^0.1002.0”。(这个版本似乎属于angular 10,而不是本地项目的angular版本(v9.1.3))
恢复此更改后,一切都重新开始工作:
@angular-devkit/build-angular“~0.901.12”

gstyhher

gstyhher4#

我在本地和远程服务器上都有相同的Linux设置。在本地它工作,远程我有“NGCC失败”。不是很有用。
所以我开始重新安装一切:nodejs,npm,ng.我试着清除和无效缓存。什么都没帮上。
然后在某个时候,我得到了:
派生后抛出ENOMEM错误
这让我想到了Node.js catch ENOMEM error thrown after spawn
我的记忆力是1GB RAM,没有swap。所以我添加了它,神奇的ngcc开始工作。
现在我想知道是swap修复了它,还是我在远程服务器上重新安装了所有东西。

jtw3ybtb

jtw3ybtb5#

我在Angular 11上得到了这个
TypeScript 4.1以上的任何版本都会导致失败
4.8+将因NGCC错误而失败
package.json中设置TypeScript版本如下:

"typescript": "~4.1.6"

相关问题