IBM Support

IBM Sterling Order Management - HookWebpackError: Reduce of empty array with no initial value Error During IBM Sterling OrderHub Customization Setup (yarn start-app)

Troubleshooting


Problem

During IBM Sterling Order Management Customization setup, when starting yarn, an error is displayed:
yarn start-app
inventory-root-config: ./src/index.js 374 bytes [built] [code generated] inventory-root-config: webpack 5.89.0 compiled successfully in 15685 ms 
inventory-audit-search-results: ✔ Browser application bundle generation complete. 
inventory-audit-search-results: <e> [webpack-dev-middleware] HookWebpackError: Reduce of empty array with no initial value 
inventory-audit-search-results: <e> at makeWebpackError (C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\webpack\lib\HookWebpackError.js:48:9) 
inventory-audit-search-results: <e> at C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\webpack\lib\Compilation.js:3060:12 
inventory-audit-search-results: <e> at eval (eval at create (C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:104:1) 
inventory-audit-search-results: <e> at fn (C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\webpack\lib\Compilation.js:480:17) inventory-audit-search-results: <e> at _next0 (eval at create (C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:101:1) 
inventory-audit-search-results: <e> at eval (eval at create (C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:118:1) 
inventory-audit-search-results: <e> at eval (eval at create (C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:12:1) 
inventory-audit-search-results: <e> at C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\webpack\lib\Compilation.js:502:10 
inventory-audit-search-results: <e> at _next1 (eval at create (C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:8:1) 
inventory-audit-search-results: <e> at eval (eval at create (C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:30:1) 
inventory-audit-search-results: <e> at C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\webpack\lib\Compilation.js:502:10 
inventory-audit-search-results: <e> at Hook.eval [as callAsync] (eval at create (C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:26:1) 
inventory-audit-search-results: <e> at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\tapable\lib\Hook.js:18:14) 
inventory-audit-search-results: <e> at C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\webpack\lib\Compilation.js:515:46 
inventory-audit-search-results: <e> at C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\copy-webpack-plugin\dist\index.js:911:9 
inventory-audit-search-results: <e> -- inner error -- inventory-audit-search-results: <e> TypeError: Reduce of empty array with no initial value inventory-audit-search-results: <e> at Array.reduce (<anonymous>) inventory-audit-search-results: <e> at MergeJsonWebpackPlugin.processFiles (C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\merge-jsons-webpack-plugin\index.js:20:18) 
inventory-audit-search-results: <e> at C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\merge-jsons-webpack-plugin\index.js:109:26 
inventory-audit-search-results: <e> at C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\webpack\lib\Compilation.js:586:56 
inventory-audit-search-results: <e> at fn (C:\Users\Administrator\Downloads\devtoolkit_docker\orderhub-code\buc-app-inventory\node_modules\webpack\lib\Compilation.js:478:10)

Symptom

The yarn start-app command stalls at the error and the customization is not compiled.

Cause

The error, "Reduce of empty array with no initial value," suggests that there is an issue with the merge-jsons-webpack-plugin during the build process. The error occurs when the reduce() method is called on an empty array without providing an initial value, which is required in such cases.

Environment

Windows Subsystem for Linux (WSL)

Diagnosing The Problem

Verify the location of the following file:
<</devtoolkit_docker/orderhub-code/<routename>/node_modules/merge-jsons-webpack-plugin\index.js>>
For e.g.
C:/Users/Administrator/Downloads/devtoolkit_docker/orderhub-code/buc-app-inventory/node_modules/merge-jsons-webpack-plugin/index.js

 

Resolving The Problem

1) Open the file <</devtoolkit_docker/orderhub-code/buc-app-inventory/node_modules/merge-jsons-webpack-plugin\index.js>> in Visual Editor.
2) Locate the processFiles() function (line 20). Look for the reduce() call and check if any of the inputs are empty.
3) Change the following line:
.reduce((acc, curr) => this.mergeDeep(acc, curr));
TO
.reduce((acc, curr) => this.mergeDeep(acc, curr),0);
Note: 0 has been added as a parameter at the last.
image-20240920160310-1
4) Clear the Yarn cache:
yarn cache clean
5) Start the yarn:
yarn start-app
The yarn start-app command start the yarn successfully.

Document Location

Worldwide

[{"Type":"MASTER","Line of Business":{"code":"LOB59","label":"Sustainability Software"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSGTJF","label":"IBM Sterling Order Management System"},"ARM Category":[{"code":"a8m0z000000cxzaAAA","label":"OrderHub"}],"ARM Case Number":"TS016988503","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]

Product Synonym

oms; orderhub

Document Information

Modified date:
20 September 2024

UID

ibm17169575