====== How to resolve 'ERR_REQUIRE_ESM' error in N4V FOR WEBI modules ====== //Anonymised summary of support ticket #837645 (2023-03-13)// ===== Symptom ===== %%The application throws an error: 'Error [ERR_REQUIRE_ESM]: require() of ES Module not supported' when using N4V FOR WEBI modules (e.g., n4v_maps.js) with Node.js version 18.14.2. The error occurs because the 'node-fetch' module version in use is not compatible with CommonJS require statements.%% ===== Environment ===== N4V FOR WEBI extensions running on SAP BusinessObjects Web Intelligence, Node.js version 18.14.2, PM2 process manager. ===== Resolution ===== - %%Stop the affected N4V module using PM2 (e.g., 'pm2 stop ').%% - %%Remove the existing 'node-fetch' module from the Node.js modules directory (e.g., 'rm -rf node-fetch').%% - %%Install the compatible version of 'node-fetch' (2.6.0) globally: 'npm install node-fetch@2.6.0 --save -g'.%% - %%Restart the N4V module using PM2: 'pm2 start '.%% - %%Verify the error no longer appears in the module logs (e.g., n4v_maps_err.log).%% ===== Other resolution ===== %%Ensure compatibility by using 'node-fetch' version 2.6.0 or earlier for Node.js environments relying on CommonJS modules. For Node.js 12.8.1 and above, use versions of 'node-fetch' prior to 3.0.0.%%