29 July, 2016

Cordova plugin download error

I was trying to download few Cordova plugin today.
So I fired a simple command, 

> cordova plugin add org.apache.cordova.device
Error: Registry returned 404 for GET on https://registry.npmjs.org/org.apache.cordova.device

I found it's strange, that all the tutorial say this is the way you should download and add a plugin. But it doesn't work and throws a strange error.

Atlast, I found that actually the problem is in repository. After cordova version 5, the naming convention of the package has been changed. Strangely the top tutorials never updated the same. I find it's worth a shout which I have learnt the hard way

All you need to transform the package name org.apache.cordova* to cordova-plugin-*
SO in the above example, the correct package name should have been cordova-plugin-device

... and the correct command would have been, 
> cordova plugin add cordova-plugin-device 
Fetching plugin "cordova-plugin-device" via npm
Installing "cordova-plugin-device" for android


and it works like a cream.

No comments:

Post a Comment