npm run build -- --prod 错误 JavaScript 堆内存不足

在 Github action 上,我正在运行 npm run build -- --prod 来为 Angular-meteor 应用程序创建生产版本。

这是我的 Github 操作文件内容-

- name: Set NPM SPACE SIZE
  run: set NODE_OPTIONS=--max_old_space_size=4096

- name: Install npm dependencies
  run: npm install

# Create production build
- name: Production Build
  run: npm run build -- --prod

现在我收到此 JavaScript heap out of memory 错误消息。

Compiling @progress/kendo-angular-popup : es2015 as esm2015

Compiling @progress/kendo-angular-dateinputs : es2015 as esm2015

Compiling @progress/kendo-angular-label : es2015 as esm2015 FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory

<--- Last few GCs --->

[2778:0x42168e0]   357894 ms: Mark-sweep 1317.3 (1453.1) -> 1317.3 (1449.6) MB,1305.5 / 0.0 ms  (average mu = 0.104,current mu = 0.015) allocation failure scavenge might not succeed [2778:0x42168e0]   359207 ms: Mark-sweep 1319.2 (1449.6) -> 1318.9 (1453.1) MB,1308.2 /
0.0 ms  (average mu = 0.057,current mu = 0.003) allocation failure scavenge might not succeed


<--- JS stacktrace --->

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

Security context: 0x34adbfe1e6c1 <JSObject> 0: builtin exit frame: stringify(this=0x34adbfe119f9 <Object map = 0x25f2945042a9>,0x1621acb026f1 <undefined>,0x3645c8c7c8f9 <JSFunction replacer (sfi = 0x1c2865791301)>,0x3645c8c7c939 <Object map = 0x1f82cd6edef1>,0x34adbfe119f9 <Object map = 0x25f2945042a9>)

1: serialize(aka serialize) [0x290b23fa12c9] [/home/runner/work/spa/spa/node_modules/serialize-javascript/index.js:162] [bytecod...

 1: 0x8fb090 node::Abort() [ng build --prod --prod]  2: 0x8fb0dc  [ng build --prod --prod]  3: 0xb0336e v8::Utils::ReportOOMFailure(v8::internal::Isolate*,char const*,bool) [ng build --prod --prod]  4: 0xb035a4 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*,bool) [ng build --prod --prod]  5: 0xef7602  [ng build --prod
--prod]  6: 0xef7708 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long,double) [ng build --prod --prod]  7: 0xf037e2 v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector,v8::GCCallbackflags) [ng build --prod --prod]  8: 0xf04114 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace,v8::internal::GarbageCollectionReason,v8::GCCallbackflags) [ng build
--prod --prod]  9: 0xf06d81 v8::internal::Heap::AllocateRawWithRetryOrFail(int,v8::internal::AllocationSpace,v8::internal::AllocationAlignment) [ng build --prod --prod] 10: 0xed69cb v8::internal::Factory::NewRawTwoByteString(int,v8::internal::Pretenureflag) [ng build --prod --prod] 11: 0x1206b60 v8::internal::IncrementalStringBuilder::Extend() [ng build --prod
--prod] 12: 0xfcac28 v8::internal::JsonStringifier::Serializestring(v8::internal::Handle<v8::internal::String>) [ng build --prod --prod] 13: 0xfcb24b v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<true>(v8::internal::Handle<v8::internal::Object>,bool,v8::internal::Handle<v8::internal::Object>) [ng build --prod
--prod] 14: 0xfcce41 v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<true>(v8::internal::Handle<v8::internal::Object>,v8::internal::Handle<v8::internal::Object>) [ng build --prod
--prod] 15: 0xfd035d v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<false>(v8::internal::Handle<v8::internal::Object>,v8::internal::Handle<v8::internal::Object>) [ng build --prod
--prod] 16: 0xfd10b9 v8::internal::JsonStringifier::Stringify(v8::internal::Handle<v8::internal::Object>,v8::internal::Handle<v8::internal::Object>,v8::internal::Handle<v8::internal::Object>) [ng build --prod --prod] 17: 0xbd7e91 v8::internal::Builtin_JsonStringify(int,v8::internal::Object**,v8::internal::Isolate*) [ng build --prod
--prod] 18: 0x235e05ddc07d  Aborted (core dumped) npm ERR! code ELIFECYCLE npm ERR! errno 134 npm ERR! yeslance@0.0.0 build: `ng build
--prod "--prod"` npm ERR! Exit status 134 npm ERR!  npm ERR! Failed at the yeslance@0.0.0 build script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR!     /home/runner/.npm/_logs/2021-08-01T15_01_41_507Z-debug.log Error: Process completed with exit code 134.

由于我已经在运行 set NODE_OPTIONS=--max_old_space_size=4096,所以我不会再收到此错误消息。有没有人知道如何解决这个问题?

speedstar119 回答:npm run build -- --prod 错误 JavaScript 堆内存不足

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/1453.html

大家都在问