I have found the best way to escape an error like this one is just to run
npm install npm update
ionic cordova prepare android
and then open the project in Android Studio to build or Debug.
and please remember to install the necessary tools to build your app, like Ionic, Cordova and/or Capacitor.