huggie
huggie

Reputation: 18247

Cordova "failed to fetch plugin" error

I've run into this "Failed to fetch plugin error" quite frequently lately. It seems especially easy to prop up if I download my own branch:

t2wu@THW-air:~/Documents/Work/John/DEMO_APP/BCAppII(dev) $ cordova plugin add https://github.com/t2wu/cordova-plugin-geofence.git#t2wu

Error: Failed to fetch plugin https://github.com/t2wu/cordova-plugin-geofence.git#t2wu via registry. Probably this is either a connection problem, or plugin spec is incorrect. Check your connection and plugin name/version/URL. Failed to get absolute path to installed module

If I download a plugin like cordova plugin add cordova-plugin-geofence, but when I have to use a specific repo, especially a branch on that repo, it fails frequently.

I am using Cordova 7.1.0. (Cordova 8 have other issues I'm not willing to touch right now.)

Upvotes: 11

Views: 23037

Answers (5)

Eliphas Masuka
Eliphas Masuka

Reputation: 78

Incase someone is still facing the issue. I still haven't figured out the root cause for this. But here is a workaround that worked for me.

I downloaded the plugin source code from the repo unzipped and added to the plugins folder with proper name (remove master and the end of the folder)

Now run your cordova add(Just to add the plugin to package.json file)

Also i find this answer helpful - Ionic - Failed to fetch plugin via registry

Upvotes: 0

Adam Johns
Adam Johns

Reputation: 36373

I saw this issue when I was running npm install before doing my platform add commands. For some reason this screwed everything up, but if I just dropped npm install it was still done as part of the platform add commands.

Upvotes: 0

Binu Purushothaman
Binu Purushothaman

Reputation: 164

In Cordova 10 and Xcode 13 the solution was to edit <App>/plugins/fetch.json and makes sure the id match with plugin name.

"cordova-labs-local-webserver": {
"source": {
  "type": "registry",
  "id": "git+https://github.com/apache/cordova-plugins.git#local-webserver"
}

Update id with plugin name

"cordova-labs-local-webserver": {
"source": {
  "type": "registry",
  "id": "cordova-labs-local-webserver"
}

Upvotes: 0

I. Ahmed
I. Ahmed

Reputation: 2534

Try the following:

cordova plugin add https://github.com/t2wu/cordova-plugin-geofence.git#t2wu --nofetch

If it doesn't work. Do the following step:

  1. Remove all platform (cordova platform rm android) and (cordova platform rm ios)

  2. Remove all plugins cordova plugin rm plugin-name.

  3. If step2 failed, then delete all plugins using a file manager from directory <projectroot>/plugins

  4. Add all plugins

  5. Add https://github.com/t2wu/cordova-plugin-geofence.git#t2wu

  6. Add all platform.

Upvotes: 13

Vladimir Pustolovskiy
Vladimir Pustolovskiy

Reputation: 51

For anyone who faced this problem, it turns out cordova is trying to fetch via registry every time when repo name do not match with plugin id. I was able to install plugins from private bitbucket just changing the repo name

Upvotes: 4

Related Questions