What is the correct way to use community plugins in v3?

So last night I was excited to get a community plugin working, which enables background location tracking in IOS and Android. I know want to create a fresh project to use the plugin, but I can’t remember which commands I used last night. To me it’s still not clear if ionic capacitor and npx cap are the same thing, or use the same capacitor package. I also don’t know how to check the version of capacitor. Something like ‘ionic capacitor version’.

This is what I do:

ionic start proj
cd proj
npm install @capacitor/cli@next @capacitor/core@next @capacitor/android@next - to update to v3
npm install @capacitor-community/background-geolocation - to install the plugin
ionic build
ionic capacitor add android

After the last command I get this error:

> capacitor.cmd init proj io.ionic.starter --npm-client npm
error: unknown option '--npm-client'
[ERROR] An error occurred while running subprocess capacitor.

At this point, any command starting with ionic capacitor … will get that error. What went wrong? What is the correct way to update to capacitor v3 and install the mentioned plugin ? In an Ionic project, when should I use ionic capacitor and when npx cap ?

EDIT:
Ionic CLI now supports Capacitor 3
npm install -g @ionic/cli@latest

OLD:
Your problem is not related to the community plugins, is that Ionic CLI doesn’t support Capacitor 3 yet, you can use a testing version that has initial support

npm install -g @ionic/cli@testing

1 Like

Thanks @jcesarmobile . Meanwhile I got is working using v3, by doing:

ionic start proj
ionic build
ionic capacitor add android
npm install @capacitor/cli@next @capacitor/core@next @capacitor/android@next @capacitor-community/background-geolocation @capacitor/app @capacitor/haptics @capacitor/keyboard
ionic capacitor sync android
ionic capacitor run android