First set up node (version v16.14.2 for this).
Next install yarn.
Next run this to install angular cli
npm install -g @angular/cli
Then run this to install ionic
npm uninstall -g ionic
npm install -g @ionic/cli
Then run this command
ionic build
Then run this command
npx cap sync
Finally you can serve the app to web by running this command now:
yarn serve