Siddharth Narsipur
Siddharth Narsipur

Reputation: 33

Capacitor CLI Version Error in Ionic. What to do?

I'm trying to add android platform to an Ionic (Angular) project.

ionic capacitor add android

It recognizes ionic capacitor add and requests me to select a platform.

? What platform would you like to add? (Use arrow keys)
> android
  ios

But as soon as I select the android platform I get this error.

? What platform would you like to add? android
[ERROR] Error while getting Capacitor CLI version.

        'capacitor' is not recognized as an internal or external command,
        operable program or batch file.

What is the problem and what do I do? Any help is appreciated. Thank you.

Upvotes: 3

Views: 13147

Answers (4)

Mansuu....
Mansuu....

Reputation: 1226

Install @capacitor/core @capacitor/cli globally, it worked for me.

Upvotes: 0

ahmnouira
ahmnouira

Reputation: 3401

Just run:

npm install @capacitor/core @capacitor/cli

Upvotes: 1

Will Madden
Will Madden

Reputation: 6945

If you're using Yarn PnP you might run into this issue because Capacitor will try to inspect the contents of node_modules to find out what its version is (and node_modules won't exist).

Upvotes: 0

Andrei Fara
Andrei Fara

Reputation: 194

Are you sure that you have installed the capacitor?

If not, you can add it using:

npm install @capacitor/core

npm install @capacitor/cli --save-dev

npx cap init

https://capacitorjs.com/docs/getting-started

Upvotes: 7

Related Questions