Err npm install @capacitor/android

Hello,

I am trying the command npm install @capacitor/android, but I am getting this error in my ionic application:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! Found: @capacitor/core@5.2.3
npm ERR! node_modules/@capacitor/core
npm ERR! @capacitor/core@“5.2.3” from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer @capacitor/core@“^5.3.0” from @capacitor/android@5.3.0
npm ERR! node_modules/@capacitor/android
npm ERR! @capacitor/android@“*” from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Ionic info is showing:

[WARN] Error loading @ionic/angular package.json: Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath ‘./package’ is
not defined by “exports” in
[WARN] Error loading @capacitor/android package.json: Error: Cannot find module ‘@capacitor/android/package’

   Require stack:
   - /usr/local/lib/node_modules/@ionic/cli/lib/project/index.js
   - /usr/local/lib/node_modules/@ionic/cli/lib/index.js
   - /usr/local/lib/node_modules/@ionic/cli/index.js
   - /usr/local/lib/node_modules/@ionic/cli/bin/ionic

Ionic:

Ionic CLI : 6.20.1 (/usr/local/lib/node_modules/@ionic/cli)
Ionic Framework : not installed
@angular-devkit/build-angular : 16.2.0
@angular-devkit/schematics : 16.2.0
@angular/cli : 16.2.0
@ionic/angular-toolkit : 9.0.0

Capacitor:

Capacitor CLI : 5.2.3
@capacitor/android : not installed
@capacitor/core : 5.2.3
@capacitor/ios : 5.2.3

Utility:

cordova-res : 0.15.4
native-run : 1.7.2

System:

NodeJS : v18.15.0 (/usr/local/bin/node)
npm : 9.5.0
OS : macOS

I uploaded today a version for the iOS of this same project. And now I was trying to upload a version for Android and I getting these errors.

Some suggestion?

update @capacitor/core too, the versions have to match

How do I update @capacitor/core?

npm install @capacitor/core@latest

2 Likes