Search code examples
androidiosionic-framework

ERROR: Unable to find command: cap build android


Similar to this question, when I run above commands I got:

[ERROR] Unable to find command: cap build android (or ios)

I considered all the given answers and points for that question, e.g., I ensured:

  1. capacitor is installed
  2. android and ios platforms are added
  3. uninstalled and installed ionic and ionic/cli and ionic/core.

None of the above solved the problem. Does any one have any idea how to get it working? Thanks in advance.


Solution

  • Well, the solution was quite easy. As for this question @jcesarmobile mentioned, the cli was very old version. You first need to uninstall it via:

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

    Then as mentioned here, in macOS, you have to remove the ionic directory (run ionic info to see where it is located).

    Then reinstall ionic via:

    npm install -g @ionic/cli