接近堆限制的无效标记压缩分配Angular 8 - JavaScript堆内存不足

新手上路,请多包涵

42% 构建 274275 个模块 1 个活动 …\src\index.js??extracted!D:\Clients\app\node_modules\sass-loader\lib\loader.js??ref–15-3!D :\src\styles.scss <— 最近几次 GC —>

[12996:000002DFC57D42F0] 43111 毫秒:清除 1335.4 (1425.0) -> 1335.3 (1426.0) MB,2.6 / 0.0 毫秒(平均 mu = 0.169,当前 mu = 0.100)分配失败 [12996:00000234697D42F0] 4DFC57D42F0] (1426.0) -> 1335.4 (1425.5) MB,375.8 / 0.0 ms(平均 mu = 0.144,当前 mu = 0.100)分配失败清除可能不会成功

<--- JS 堆栈跟踪 —>

==== JS 堆栈跟踪 ==========================================

>  0: ExitFrame [pc: 00000257D3FDC5C1] Security context: 0x00b77541e6e9 <JSObject>
> 1: createNode [000001A31ED4EFF1] [D:\Clients\app\node_modules\typescript\lib\typescript.js:~16489]
>
> ```
>
> \[pc=00000257D55AD889\](this=0x02b823cedf89,kind=275,pos=-=-1,end=-1) 2: createPropertyAssignment \[000001A31ED54669\] \[D:\\Clients\\app\\node_modules\\typescript\\lib\\typescri ...
>
> 致命错误:无效标记压缩接近堆限制分配失败 \- JavaScript 堆内存不足 1: 00007FF76C26DD8A v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+4506 2: 00007FF76C248886 node::MakeCallback+4534 3: 00007FF76C249203 4:0node_module_register+2 00007FF76C5630DE v8::internal::FatalProcessOutOfMemory+846 5: 00007FF76C56300F v8::internal::FatalProcessOutOfMemory+639 6: 00007FF76C749804 v8::internal::Heap::MaxHeapGrowingFactor+9620 7: 00007FF76C7407E6 v8::internal::ScavengeJob::operator =+24550 8:00007FF76C73EE3C v8::internal::ScavengeJob::operator=+17980 9:00007FF76C747B87 v8::internal::Heap::MaxHeapGrowingFactor+2327 10:00007FF76C747C06 v8::internal::HeapingGrowingFactor+245::4HeapFactor : 00007FF76C871EA7 v8::internal::Factory::NewFillerObject+55 12: 00007FF76C8EF096 v8::internal::operator<<+73494 13: 00000257D3FDC5C1

我已经尝试过这个解决方案: [https](https://github.com/angular/angular-cli/issues/5618#issuecomment-450151214) ://github.com/angular/angular-cli/issues/5618#issuecomment-450151214

IE

_包.json_

“scripts”: { “ng”: “ng”, “ng-high-memory”: “node –max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng”,// here “start”: “ng serve”, “build:prod”: “ng build –configuration=prod”, },

”`

在那之后

npm 运行 ng-high-memory –build –prod

但它说

> > metronic-angular@6.0.0 ng-high-memory D:\Clients\app
> > node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng
>
> Available Commands:   add Adds support for an external library to your
> project.   analytics Configures the gathering of Angular CLI usage
> metrics. See https://v8.angular.io/cli/usage-analytics-gathering.
> build (b) Compiles an Angular app into an output directory named dist/
> at the given output path. Must be executed from within a workspace
> directory.   deploy (d) Invokes the deploy builder for a specified
> project or for the default project in the workspace.   config
> Retrieves or sets Angular configuration values in the angular.json
> file for the workspace.   doc (d) Opens the official Angular
> documentation (angular.io) in a browser, and searches for a given
> keyword.   e2e (e) Builds and serves an Angular app, then runs
> end-to-end tests using Protractor.   generate (g) Generates and/or
> modifies files based on a schematic.   help Lists available commands
> and their short descriptions.   lint (l) Runs linting tools on Angular
> app code in a given project folder.   new (n) Creates a new workspace
> and an initial Angular app.   run Runs an Architect target with an
> optional custom builder configuration defined in your project.   serve
> (s) Builds and serves your app, rebuilding on file changes.   test (t)
> Runs unit tests in a project.   update Updates your application and
> its dependencies. See https://update.angular.io/   version (v) Outputs
> Angular CLI version.   xi18n Extracts i18n messages from source code.
>
> For more detailed help run "ng [command name] --help"

那么我怎样才能正确运行这个命令呢?

注意: 我使用最新的 Angular 即 "@angular/core": "^8.2.14""@angular/cli": "^8.3.19"

原文由 Sampath 发布,翻译遵循 CC BY-SA 4.0 许可协议

阅读 877
2 个回答

这在 2019 年 11 月 对我有用

我已经像这样更新到最新的Angular: ng update @angular/cli@^8 @angular/core@^8

然后

包.json

 "scripts": {
    "ng-high-memory": "node --max_old_space_size=8000 ./node_modules/@angular/cli/bin/ng build --configuration=prod",
}

在那之后:

 npm run ng-high-memory

网址: JavaScript 堆内存不足

原文由 Sampath 发布,翻译遵循 CC BY-SA 4.0 许可协议

将节点 js 版本升级到 v12 或比您当前使用的版本更高的版本。

原文由 Onen simon 发布,翻译遵循 CC BY-SA 4.0 许可协议

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题