简体   繁体   中英

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.

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

如果您使用 Yarn PnP,您可能会遇到此问题,因为 Capacitor 将尝试检查node_modules的内容以找出它的版本(并且node_modules将不存在)。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM