当我尝试在netlify中部署React.js代码时,部署过程被取消,并显示以下错误消息。
忘记分配失败-Javascript堆内存不足。
所以我通过添加此命令来增加内存空间大小,
-max-old-space-size = 2048
但是在部署过程中,我仍然收到相同的错误消息。 这是我在Netlify中的部署构建命令,
npm运行build --node-flags --max-old-space-size = 2048 --no-warnings
它仅在本地工作,但在Netlify部署中失败。 我在下面添加了错误消息日志供您参考,
4:09:50 AM: v8::internal::JsonStringifier::Result v8::internal::JsonStringifier::Serialize_<false>(v8::internal::Handle<v8::internal::Object>, bool, v8::internal::Handle<v8::internal::Object>) [/opt/buildhome/.nvm/versions/node/v8.16.0/bin/node]
4:09:50 AM: 12: v8::internal::JsonStringifier::Stringify(v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>, v8::internal::Handle<v8::internal::Object>) [/opt/buildhome/.nvm/versions/node/v8.16.0/bin/node]
4:09:50 AM: 13:
4:09:50 AM: v8::internal::Builtin_JsonStringify(int, v8::internal::Object**, v8::internal::Isolate*) [/opt/buildhome/.nvm/versions/node/v8.16.0/bin/node]
4:09:50 AM: 14: 0x6cb5090697d
4:11:53 AM: <--- Last few GCs --->
4:11:53 AM: [1396:0x26865c0] 225936 ms: Mark-sweep 1249.1 (1432.4) -> 1248.6 (1441.4) MB, 1739.7 / 0.0 ms allocation failure GC in old space requested
4:11:53 AM: [1396:0x26865c0] 227639 ms: Mark-sweep 1248.6 (1441.4) -> 1248.6 (1385.4) MB, 1703.0 / 0.0 ms last resort GC in old space requested
4:11:53 AM: [1396:0x26865c0] 229446 ms: Mark-sweep 1248.6 (1385.4) -> 1248.6 (1369.9) MB, 1807.1 / 0.0 ms last resort GC in old space requested
4:11:53 AM: <--- JS stacktrace --->
4:11:53 AM: ==== JS stack trace =========================================
4:11:53 AM: Security context: 0x15788a425891 <JSObject>
4:11:53 AM: 1: _send [internal/child_process.js:666] [bytecode=0x3fb687e9c49 offset=586](this=0x1226496828d1 <process map = 0x28b355b8a341>,message=0x52551c47999 <Object map = 0x387d7463f3a1>,handle=0x2fcee17022d1 <undefined>,options=0x52551c47a31 <Object map = 0x387d7463f3f9>,callback=0x2fcee17022d1 <undefined>)
4:11:53 AM: 2: send [internal/child_process.js:576] [bytecode=0x3fb687e9301 offset=131](this=0x1226...
4:11:53 AM: FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
4:11:53 AM: 1:
4:11:53 AM: node::Abort() [/opt/buildhome/.nvm/versions/node/v8.16.0/bin/node]
4:11:53 AM: 2:
4:11:53 AM: 0x8cd14c [/opt/buildhome/.nvm/versions/node/v8.16.0/bin/node]
4:11:53 AM: 3:
4:11:53 AM: v8::Utils::ReportOOMFailure(char const*, bool) [/opt/buildhome/.nvm/versions/node/v8.16.0/bin/node]
4:11:53 AM: 4:
4:11:53 AM: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [/opt/buildhome/.nvm/versions/node/v8.16.0/bin/node]
4:11:53 AM: 5:
4:11:53 AM: v8::internal::Factory::NewRawTwoByteString(int, v8::internal::PretenureFlag) [/opt/buildhome/.nvm/versions/node/v8.16.0/bin/node]
4:11:53 AM: 6:
4:11:53 AM: v8::internal::String::SlowFlatten(v8::internal::Handle<v8::internal::ConsString>, v8::internal::PretenureFlag)
4:11:53 AM: [/opt/buildhome/.nvm/versions/node/v8.16.0/bin/node]
预先感谢