TypeError: Cannot read properties of undefined (reading 'compilation') Ionic 5.4.16

I am upgrading to Cordova 11 using this link https://ionic.zendesk.com/hc/en-us/articles/7891143965975?input_string=build+failure+after+migrating+to+cordova+11

I have done the steps but while building I am getting the below error. I am not sure what is causing this error and how to resolve it. Can someone guide me?

[08:31:51]  webpack started ...
[08:31:52]  ionic-app-script task: "build"
[08:31:52]  TypeError: Cannot read properties of undefined (reading 'compilation')
TypeError: Cannot read properties of undefined (reading 'compilation')
    at DefinePlugin.apply (C:\NetQuarry\Adrian\Source\MatrixCR.Mobile\node_modules\webpack\lib\DefinePlugin.js:97:18)
    at Compiler.apply (C:\NetQuarry\Adrian\Source\MatrixCR.Mobile\node_modules\@ionic\app-scripts\node_modules\tapable\lib\Tapable.js:375:16)
    at webpack (C:\NetQuarry\Adrian\Source\MatrixCR.Mobile\node_modules\@ionic\app-scripts\node_modules\webpack\lib\webpack.js:33:19)
    at C:\NetQuarry\Adrian\Source\MatrixCR.Mobile\node_modules\@ionic\app-scripts\dist\webpack.js:132:24
    at new Promise (<anonymous>)
    at runWebpackFullBuild (C:\NetQuarry\Adrian\Source\MatrixCR.Mobile\node_modules\@ionic\app-scripts\dist\webpack.js:113:12)
    at webpackWorker (C:\  \  \Source\MatrixCR.Mobile\node_modules\@ionic\app-scripts\dist\webpack.js:70:19)
    at Object.webpack (C:\  \  \Source\MatrixCR.Mobile\node_modules\@ionic\app-scripts\dist\webpack.js:29:12)
    at bundleWorker (C:\  \  \Source\MatrixCR.Mobile\node_modules\@ionic\app-scripts\dist\bundle.js:13:22)
    at Object.bundle (C:\  \  \Source\MatrixCR.Mobile\node_modules\@ionic\app-scripts\dist\bundle.js:6:12)
[ERROR] An error occurred while running subprocess ionic-app-scripts.
Ionic:

   Ionic CLI          : 5.4.16 (C:\Users\ AppData\Roaming\npm\node_modules\ionic)
   Ionic Framework    : ionic-angular 3.9.2
   @ionic/app-scripts : 3.2.4

Cordova:

   Cordova CLI       : 11.0.0
   Cordova Platforms : android 11.0.0
   Cordova Plugins   : cordova-plugin-ionic-keyboard 2.2.0, cordova-plugin-ionic-webview 5.0.0, cordova-plugin-ionic 5.5.3, (and 17 other plugins)        

Utility:

   cordova-res : not installed
   native-run  : not installed

System:

   NodeJS : v16.13.0 (C:\Program Files\nodejs\node.exe)
   npm    : 9.1.2
   OS     : Windows 10

package.json

{
  "name": "MatrixCRApp",
  "version": "1.3.2",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "start": "ionic-app-scripts serve",
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint"
  },
  "config": {
    "ionic_uglifyjs": "./config/uglifyjs.config.js"
  },
  "dependencies": {
    "@angular/animations": "5.2.11",
    "@angular/common": "5.2.11",
    "@angular/compiler": "5.2.11",
    "@angular/compiler-cli": "5.2.11",
    "@angular/core": "5.2.11",
    "@angular/forms": "5.2.11",
    "@angular/http": "5.2.11",
    "@angular/platform-browser": "5.2.11",
    "@angular/platform-browser-dynamic": "5.2.11",
    "@ionic-native/app-version": "^4.20.0",
    "@ionic-native/core": "^4.20.0",
    "@ionic-native/device": "^4.20.0",
    "@ionic-native/file": "^4.20.0",
    "@ionic-native/file-chooser": "^4.20.0",
    "@ionic-native/file-opener": "^4.20.0",
    "@ionic-native/file-path": "^4.20.0",
    "@ionic-native/file-picker": "^4.20.0",
    "@ionic-native/fingerprint-aio": "^4.20.0",
    "@ionic-native/http": "^4.20.0",
    "@ionic-native/image-picker": "^4.20.0",
    "@ionic-native/in-app-browser": "^4.20.0",
    "@ionic-native/network": "^4.20.0",
    "@ionic-native/onesignal": "^4.20.0",
    "@ionic-native/pin-dialog": "^4.20.0",
    "@ionic-native/secure-storage": "^4.20.0",
    "@ionic-native/spinner-dialog": "^4.20.0",
    "@ionic-native/splash-screen": "^4.20.0",
    "@ionic-native/status-bar": "^4.20.0",
    "@ionic/pro": "^2.0.4",
    "@ionic/storage": "^2.2.0",
    "@ngrx/core": "^1.2.0",
    "@ngrx/effects": "5.2",
    "@ngrx/entity": "5.2",
    "@ngrx/store": "5.2",
    "@openid/appauth": "^0.3.5",
    "@types/jquery": "^3.3.1",
    "ajv": "^6.10.0",
    "cordova-ios": "6.1.0",
    "cordova-plugin-add-swift-support": "^2.0.2",
    "cordova-plugin-advanced-http": "2.0.6",
    "cordova-plugin-app-version": "^0.1.14",
    "cordova-plugin-customurlscheme": "^5.0.2",
    "cordova-plugin-device": "2.0.2",
    "cordova-plugin-file": "^6.0.2",
    "cordova-plugin-file-opener2": "git+https://github.com/CitadelApp/cordova-plugin-file-opener2.git",
    "cordova-plugin-file-transfer": "^1.7.1",
    "cordova-plugin-filechooser": "^1.2.0",
    "cordova-plugin-filepath": "^1.6.0",
    "cordova-plugin-filepicker": "^1.1.6",
    "cordova-plugin-fingerprint-aio": "^3.0.1",
    "cordova-plugin-inappbrowser": "^5.0.0",
    "cordova-plugin-ionic": "^5.5.3",
    "cordova-plugin-ionic-keyboard": "^2.2.0",
    "cordova-plugin-ionic-webview": "^5.0.0",
    "cordova-plugin-iroot": "^2.1.0",
    "cordova-plugin-native-spinner": "1.1.3",
    "cordova-plugin-network-information": "^2.0.2",
    "cordova-plugin-pin-dialog": "^0.1.3",
    "cordova-plugin-safariviewcontroller": "^1.6.0",
    "cordova-plugin-secure-storage-echo": "^5.1.1",
    "cordova-plugin-statusbar": "^2.4.3",
    "ionic-angular": "3.9.2",
    "ionic-cache": "^3.1.3",
    "ionicons": "3.0.0",
    "js-sha256": "^0.9.0",
    "onesignal-cordova-plugin": "^2.11.4",
    "rxjs": "5.5.11",
    "sw-toolbox": "3.6.0",
    "text-encoding": "^0.6.4",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^3.2.4",
    "cordova-android": "^11.0.0",
    "typescript": "~2.6.2",
    "uglifyjs-webpack-plugin": "^1.3.0",
    "webpack-obfuscator": "^0.18.0"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-ionic-keyboard": {},
      "cordova-plugin-safariviewcontroller": {},
      "cordova-plugin-inappbrowser": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-network-information": {},
      "cordova-plugin-ionic": {
        "APP_ID": "317d89a1",
        "CHANNEL_NAME": "master",
        "UPDATE_METHOD": "none",
        "MAX_STORE": "2",
        "WARN_DEBUG": "true",
        "UPDATE_API": "https://api.ionicjs.com",
        "MIN_BACKGROUND_DURATION": "30"
      },
      "cordova-plugin-customurlscheme": {
        "URL_SCHEME": "com.matrix.cr",
        "ANDROID_SCHEME": " ",
        "ANDROID_HOST": " ",
        "ANDROID_PATHPREFIX": "/"
      },
      "cordova-plugin-pin-dialog": {},
      "onesignal-cordova-plugin": {},
      "cordova-plugin-fingerprint-aio": {
        "FACEID_USAGE_DESCRIPTION": "for secure login on Matrix CR"
      },
      "cordova-plugin-file": {},
      "cordova-plugin-filechooser": {},
      "cordova-plugin-filepath": {},
      "cordova-plugin-file-opener2": {
        "ANDROID_SUPPORT_V4_VERSION": "27.+"
      },
      "cordova-plugin-filepicker": {},
      "cordova-plugin-app-version": {},
      "cordova-plugin-iroot": {
        "ENABLE_BUSYBOX_CHECK": "true"
      },
      "cordova-plugin-ionic-webview": {
        "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+"
      },
      "cordova-plugin-secure-storage-echo": {},
      "cordova-plugin-advanced-http": {},
      "cordova-plugin-device": {},
      "cordova-plugin-native-spinner": {}
    },
    "platforms": [
      "ios",
      "android"
    ]
  }
}

Config xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.matrix.cr" version="1.3.2" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Matrix CR</name>
    <description>Companion Mobile App for the Matrix-CR procurement system.</description>
    <author email="enquiries.cr@matrix-scm.com" href="http://www.matrix-scm.com/">Matrix SCM</author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <preference name="ScrollEnabled" value="false" />
    <preference name="android-minSdkVersion" value="22" />
    <preference name="android-targetSdkVersion" value="32" />
    <preference name="BackupWebStorage" value="none" />
    <preference name="SplashMaintainAspectRatio" value="true" />
    <preference name="FadeSplashScreenDuration" value="300" />
    <preference name="SplashShowOnlyFirstTime" value="false" />
    <preference name="SplashScreen" value="screen" />
    <preference name="SplashScreenDelay" value="3000" />
    <preference name="StatusBarOverlaysWebView" value="false" />
    <preference name="UseSwiftLanguageVersion" value="4.0" />
    <preference name="AndroidLaunchMode" value="singleInstance" />
    <platform name="android">
        <allow-intent href="market:*" />
        <icon density="ldpi" src="resources/android/icon/drawable-ldpi-icon.png" />
        <icon density="mdpi" src="resources/android/icon/drawable-mdpi-icon.png" />
        <icon density="hdpi" src="resources/android/icon/drawable-hdpi-icon.png" />
        <icon density="xhdpi" src="resources/android/icon/drawable-xhdpi-icon.png" />
        <icon density="xxhdpi" src="resources/android/icon/drawable-xxhdpi-icon.png" />
        <icon density="xxxhdpi" src="resources/android/icon/drawable-xxxhdpi-icon.png" />
        <hook src="hooks/copy_android_notification_icons.js" type="after_prepare" />
        <preference name="AndroidWindowSplashScreenAnimatedIcon" value="resources/android/icon/drawable-xxxhdpi-icon.png" />
        <preference name="AndroidXEnabled" value="true" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <config-file parent="NSLocationAlwaysUsageDescription" platform="ios" target="*-Info.plist">
            <string>One Signal Notifications</string>
        </config-file>
        <config-file parent="NSLocationWhenInUseUsageDescription" platform="ios" target="*-Info.plist">
            <string>One Signal Notifications</string>
        </config-file>
        <icon height="57" src="resources/ios/icon/icon.png" width="57" />
        <icon height="114" src="resources/ios/icon/icon@2x.png" width="114" />
        <icon height="40" src="resources/ios/icon/icon-40.png" width="40" />
        <icon height="80" src="resources/ios/icon/icon-40@2x.png" width="80" />
        <icon height="120" src="resources/ios/icon/icon-40@3x.png" width="120" />
        <icon height="50" src="resources/ios/icon/icon-50.png" width="50" />
        <icon height="100" src="resources/ios/icon/icon-50@2x.png" width="100" />
        <icon height="60" src="resources/ios/icon/icon-60.png" width="60" />
        <icon height="120" src="resources/ios/icon/icon-60@2x.png" width="120" />
        <icon height="180" src="resources/ios/icon/icon-60@3x.png" width="180" />
        <icon height="72" src="resources/ios/icon/icon-72.png" width="72" />
        <icon height="144" src="resources/ios/icon/icon-72@2x.png" width="144" />
        <icon height="76" src="resources/ios/icon/icon-76.png" width="76" />
        <icon height="152" src="resources/ios/icon/icon-76@2x.png" width="152" />
        <icon height="167" src="resources/ios/icon/icon-83.5@2x.png" width="167" />
        <icon height="29" src="resources/ios/icon/icon-small.png" width="29" />
        <icon height="58" src="resources/ios/icon/icon-small@2x.png" width="58" />
        <icon height="87" src="resources/ios/icon/icon-small@3x.png" width="87" />
        <icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
        <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640" />
        <splash height="1334" src="resources/ios/splash/Default-667h.png" width="750" />
        <splash height="2208" src="resources/ios/splash/Default-736h.png" width="1242" />
        <splash height="1242" src="resources/ios/splash/Default-Landscape-736h.png" width="2208" />
        <splash height="1536" src="resources/ios/splash/Default-Landscape@2x~ipad.png" width="2048" />
        <splash height="2048" src="resources/ios/splash/Default-Landscape@~ipadpro.png" width="2732" />
        <splash height="768" src="resources/ios/splash/Default-Landscape~ipad.png" width="1024" />
        <splash height="2048" src="resources/ios/splash/Default-Portrait@2x~ipad.png" width="1536" />
        <splash height="2732" src="resources/ios/splash/Default-Portrait@~ipadpro.png" width="2048" />
        <splash height="1024" src="resources/ios/splash/Default-Portrait~ipad.png" width="768" />
        <splash height="960" src="resources/ios/splash/Default@2x~iphone.png" width="640" />
        <splash height="480" src="resources/ios/splash/Default~iphone.png" width="320" />
        <splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
        <hook src="hooks/copy_ios_pinned_cert.js" type="after_prepare" />
    </platform>
    <plugin name="cordova-plugin-ionic-keyboard" spec="^2.1.3" />
    <plugin name="cordova-plugin-safariviewcontroller" spec="^1.5.4" />
    <plugin name="cordova-plugin-ionic" spec="^5.3.0">
        <variable name="APP_ID" value="317d89a1" />
        <variable name="CHANNEL_NAME" value="master" />
        <variable name="UPDATE_METHOD" value="none" />
        <variable name="MAX_STORE" value="2" />
        <variable name="WARN_DEBUG" value="true" />
        <variable name="UPDATE_API" value="https://api.ionicjs.com" />
        <variable name="MIN_BACKGROUND_DURATION" value="30" />
    </plugin>
    <plugin name="cordova-plugin-customurlscheme" spec="^4.3.0">
        <variable name="URL_SCHEME" value="com.matrix.cr" />
        <variable name="ANDROID_SCHEME" value=" " />
        <variable name="ANDROID_HOST" value=" " />
        <variable name="ANDROID_PATHPREFIX" value="/" />
    </plugin>
    <plugin name="cordova-plugin-pin-dialog" spec="^0.1.3" />
    <plugin name="onesignal-cordova-plugin" spec="^2.4.6" />
    <plugin name="cordova-plugin-fingerprint-aio" spec="^1.6.0" />
    <plugin name="cordova-plugin-file" spec="^6.0.1" />
    <plugin name="cordova-plugin-filechooser" spec="^1.2.0" />
    <plugin name="cordova-plugin-filepath" spec="^1.5.1" />
    <plugin name="cordova-plugin-file-opener2" spec="^2.2.0">
        <variable name="ANDROID_SUPPORT_V4_VERSION" value="27.+" />
    </plugin>
    <plugin name="cordova-plugin-filepicker" spec="^1.1.5" />
    <plugin name="cordova-plugin-app-version" spec="^0.1.9" />
    <plugin name="cordova-plugin-iroot" spec="^0.8.0">
        <variable name="ENABLE_BUSYBOX_CHECK" value="true" />
    </plugin>
    <plugin name="cordova-plugin-ionic-webview" spec="^4.0.1">
        <variable name="ANDROID_SUPPORT_ANNOTATIONS_VERSION" value="27.+" />
    </plugin>
    <plugin name="cordova-plugin-inappbrowser" spec="git+https://github.com/Onegini/cordova-plugin-inappbrowser.git" />
    <plugin name="cordova-plugin-statusbar" spec="^2.4.2" />
    <plugin name="cordova-plugin-network-information" spec="^2.0.1" />
    <plugin name="cordova-plugin-secure-storage-echo" spec="^5.0.0" />
    <plugin name="cordova-plugin-advanced-http" spec="2.0.6" />
    <plugin name="cordova-plugin-device" spec="2.0.2" />
    <plugin name="cordova-plugin-native-spinner" spec="1.1.3" />
    <engine name="ios" spec="6.1.0" />
    <edit-config file="app/src/main/AndroidManifest.xml" mode="merge" target="/manifest/application/activity">
        <application android:exported="true" />
    </edit-config>
    <resource-file src="resources/android/colors.xml" target="app/src/main/res/values/colors.xml" />
</widget>