Angular 8 FATAL ERROR:CALL_AND_RETRY_LAST分配失败-JavaScript堆内存不足

问题描述 投票:-1回答:1

我有一个Angular 8应用程序,几周前可以很好地进行编译。今天,我做了一些小的更改,并使用以下命令生成了产品:

ng build  --prod --output-hashing none

并且我收到这些错误:

C:\project path\Client>ng build  --prod --output-hashing none
Browserslist: caniuse-lite is outdated. Please run next command `npm update`

chunk {0} runtime.js (runtime) 1.41 kB [entry] [rendered]
chunk {1} main.js (main) 128 bytes [initial] [rendered]
chunk {2} polyfills.js (polyfills) 130 bytes [initial] [rendered]
chunk {3} polyfills-es5.js (polyfills-es5) 70 kB [initial] [rendered]
chunk {4} styles.css (styles) 739 kB [initial] [rendered]
chunk {scripts} scripts.js (scripts) 163 kB [entry] [rendered]
Date: 2020-03-25T22:11:58.080Z - Hash: f1fa96aaaa845bd79517 - Time: 88244ms

<--- Last few GCs --->

[17616:0000019B35A393D0]   109256 ms: Mark-sweep 1334.4 (1384.5) -> 1334.3 (1384.0) MB, 463.5 / 0.0 ms  (average mu = 0.684, current mu = 0.000) last resort GC in old space requested
[17616:0000019B35A393D0]   109772 ms: Mark-sweep 1334.3 (1384.0) -> 1334.3 (1384.0) MB, 516.1 / 0.0 ms  (average mu = 0.491, current mu = 0.000) last resort GC in old space requested


<--- JS stacktrace --->

==== JS stack trace =========================================

    0: ExitFrame [pc: 00000334E4B5C5C1]
Security context: 0x016d3849e6e9 <JSObject>
    1: DoJoin(aka DoJoin) [0000016D38485E91] [native array.js:~87] [pc=00000334E561F169](this=0x036c721826f1 <undefined>,l=0x035b6f848e01 <JSArray[5612]>,m=5612,A=0x036c721828c9 <true>,w=0x02ea66ab46d9 <String[1]\: \n>,v=0x036c721829a1 <false>)
    2: Join(aka Join) [0000016D38485EE1] [native array.js:~112] [pc=00000334E574B2F8](this=0x036c721826f1 <undefi...

FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
 1: 00007FF6017AC6AA v8::internal::GCIdleTimeHandler::GCIdleTimeHandler+4506
 2: 00007FF601787416 node::MakeCallback+4534
 3: 00007FF601787D90 node_module_register+2032
 4: 00007FF601AA189E v8::internal::FatalProcessOutOfMemory+846
 5: 00007FF601AA17CF v8::internal::FatalProcessOutOfMemory+639
 6: 00007FF601C87F94 v8::internal::Heap::MaxHeapGrowingFactor+9620
 7: 00007FF601C8645B v8::internal::Heap::MaxHeapGrowingFactor+2651
 8: 00007FF601DB02BB v8::internal::Factory::AllocateRawWithImmortalMap+59
 9: 00007FF60206AE12 v8::internal::wasm::WasmModuleBuilder::WriteAsmJsOffsetTable+201282
10: 00000334E4B5C5C1

这里是package.json

{
  "name": "gwfo",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build  --prod --output-hashing none",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "~8.1.0",
    "@angular/common": "~8.1.0",
    "@angular/compiler": "~8.1.0",
    "@angular/core": "~8.1.0",
    "@angular/forms": "~8.1.0",
    "@angular/platform-browser": "~8.1.0",
    "@angular/platform-browser-dynamic": "~8.1.0",
    "@angular/router": "~8.1.0",
    "@ngx-translate/core": "^11.0.1",
    "@ngx-translate/http-loader": "^4.0.0",
    "@progress/kendo-angular-common": "^1.0.0",
    "@progress/kendo-angular-l10n": "^2.0.0",
    "@progress/kendo-angular-menu": "^2.0.0",
    "@progress/kendo-angular-popup": "^3.0.1",
    "@progress/kendo-angular-scrollview": "^3.0.0",
    "@progress/kendo-theme-default": "latest",
    "bootstrap": "^4.3.1",
    "browserslist": "^4.8.2",
    "caniuse-lite": "^1.0.30001016",
    "classlist.js": "^1.1.20150312",
    "font-awesome": "^4.7.0",
    "jquery": "^3.4.1",
    "popper.js": "^1.16.0",
    "rxjs": "~6.4.0",
    "tslib": "^1.9.0",
    "web-animations-js": "^2.3.2",
    "zone.js": "~0.9.1"
  },
  "devDependencies": {
    "@angular-devkit/build-angular": "~0.801.0",
    "@angular/cli": "~8.1.0",
    "@angular/compiler-cli": "~8.1.0",
    "@angular/language-service": "~8.1.0",
    "@types/jasmine": "~3.3.8",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "^5.2.0",
    "jasmine-core": "~3.4.0",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~4.1.0",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~2.0.1",
    "karma-jasmine-html-reporter": "^1.4.0",
    "protractor": "~5.4.0",
    "ts-node": "~7.0.0",
    "tslint": "~5.15.0",
    "typescript": "~3.4.3"
  }
}

请指导应采取哪些步骤解决此问题

angular build out-of-memory
1个回答
0
投票

尝试一下

node --max_old_space_size=8192 node_modules/@angular/cli/bin/ng build --prod=true --outputHashing=none
© www.soinside.com 2019 - 2024. All rights reserved.