Lately, I had the following error after adding adding ionic to an existing angular project

ng add @ionic/angular

This gave me the following error:

Invalid projectType for app: undefined

Solution

Uninstall ionic cli and install the latest version

npm uninstall -g @ionic/cli
npm install -g @ionic/cli@latest