I've following dependencies and huge set of components in react and using storybook and webpack,
"@storybook/react": "5.0.6",
"styled-components": "5.0.1",
"typescript": "3.5",
"webpack": "4.39.3",
"webpack-cli": "3.3.7"
locally everything was working fine while building storybook at remote it was continuously failing at this step, giving this error :-
16:19:16 <s> [webpack.Progress] 92% chunk asset optimization TerserPlugin
16:21:20
16:21:20 <--- Last few GCs --->
16:21:20
16:21:20 [430:0x3f22bb0] 291204 ms: Mark-sweep 1403.2 (1484.9) -> 1403.2 (1484.9) MB, 1152.6 / 0.0 ms allocation failure GC in old space requested
16:21:20 [430:0x3f22bb0] 292437 ms: Mark-sweep 1403.2 (1484.9) -> 1403.0 (1453.9) MB, 1233.4 / 0.0 ms last resort GC in old space requested
16:21:20 [430:0x3f22bb0] 293968 ms: Mark-sweep 1403.0 (1453.9) -> 1403.0 (1453.9) MB, 1531.0 / 0.0 ms last resort GC in old space requested
16:21:20
16:21:20
16:21:20 <--- JS stacktrace --->
16:21:20
16:21:20 ==== JS stack trace =========================================
16:21:20
16:21:20 Security context: 0x3e34ae9a5879 <JSObject>
16:21:20 1: /* anonymous */ [/home/jenkins/workspace/FlashtoolsUikit-03-Npm-Package-Update-Storybook/node_modules/webpack/node_modules/source-map/lib/source-node.js:~342] [pc=0x18aaeba69706](this=0xc21c728c209 <JSGlobal Object>,chunk=0x19b226eb79a1 <String[2]: }>,original=0x1f48ac1ce9 <Object map = 0x3723b1482259>)
16:21:20 2: SourceNode_walk [/home/jenkins/workspace/FlashtoolsUikit-03-Npm-Package-Update...
16:21:20
16:21:20 FATAL ERROR: CALL_AND_RETRY_LAST Allocation failed - JavaScript heap out of memory
16:21:20 1: node::Abort() [node]
16:21:20 2: 0x8c21ec [node]
16:21:20 3: v8::Utils::ReportOOMFailure(char const*, bool) [node]
16:21:20 4: v8::internal::V8::FatalProcessOutOfMemory(char const*, bool) [node]
16:21:20 5: v8::internal::Factory::NewUninitializedFixedArray(int) [node]
16:21:20 6: 0xd4b153 [node]
16:21:20 7: v8::internal::Runtime_GrowArrayElements(int, v8::internal::Object**, v8::internal::Isolate*) [node]
16:21:20 8: 0x18aaeb5042fd
16:21:48 sh: line 1: 420 Aborted (core dumped) npm run build:storybook
16:21:48 npm ERR! code ELIFECYCLE
16:21:48 npm ERR! errno 134
tried updating webpack (terser plugin specially) after google search but no luck, keep on getting this error continuously.
After passing following node option along with other build command i.e.
export "NODE_OPTIONS=--max_old_space_size=2000"
no more out of heap memory, issue got resolved.