Error while installing cordova inappbrowser plugins

Hi all
i have recently started using ionic. I m trying to use native plugins such as in-app-browser, camera etc. However when i try to install them using the below command(as mentioned in ionic documentation):


ionic cordova plugin add cordova-plugin-inappbrowser


It throws me the following error:


F:\IonicProjects\demoBlank>ionic cordova plugin add cordova-plugin-inappbrowser
? The plugin @ionic/cli-plugin-cordova is not installed. Would you like to inst
all it and continue? Yes

npm install --save-dev --save-exact @ionic/cli-plugin-cordova@latest
√ Running command - done!
cordova plugin add cordova-plugin-inappbrowser --save
× Running command - failed!

[ERROR] Cordova encountered an error.
You may get more insight by running the Cordova command above directly.

[ERROR] An error occurred while running cordova plugin add
cordova-plugin-inappbrowser --save (exit code 1):

    Error: Failed to fetch plugin cordova-plugin-inappbrowser@1.7.1 via
    registry.
    Probably this is either a connection problem, or plugin spec is
    incorrect.
    Check your connection and plugin name/version/URL.
    Error: cmd: Command failed with exit code ENOENT

the same error is coming while installing other cordova-plugins such as camera.

my ionic info is:


F:\IonicProjects\demoBlank>ionic info

cli packages: (F:\IonicProjects\demoBlank\node_modules)

@ionic/cli-plugin-cordova       : 1.6.2
@ionic/cli-plugin-ionic-angular : 1.4.1
@ionic/cli-utils                : 1.7.0
ionic (Ionic CLI)               : 3.7.0

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 2.1.3
Cordova Platforms  : none
Ionic Framework    : ionic-angular 3.6.0

System:

Node : v6.11.2
OS   : Windows 10
npm  : 3.10.10

while setting the development environment i hadn’t add platforms to my projects, is it neccessary to add platforms before installing cordova plugins.
also my network connectoion seems to have no problem as all others npm modules have been installed properly.

please help me on this as i m stuck on it.
Thanks in advance

I used to have this problem too, It error, because of Android platform, if you have Android platform testing remove it,
or another ways it work for me is to downgrade Cordova,

npm uninstall cordova ionic
npm cache clean -f
npm install -g cordova@6.5.0

this work for me , you can try it, if it work for you or not.

Hi Chungtheng,
Thanks for the answer.
I just wanted to confirm that did u face the similar problem on given solution for windows? Bcoz i m using the windows OS as u might have seen.

So please confirm this thing once do that i can go ahead with the solution provider by u.

Yes, I have this problem too, I can add screen_orientation

@Chungtheng

Was your development OS was windows or Mac.

I m using the windows machine for development but tge commands u have provided are for Mac.
So please clarify this that what steps i should follow on windows to solve the same problem

I use Window and Mac.

Run cordova plugin add cordova-plugin-inappbrowser --save --debug please and post the complete output.
(Run cordova plugin remove cordova-plugin-inappbrowser --save before to make sure there are no parts of the plugin on your project)

Hi Sujan12
As advised by u i have run the following commands but got the same errors:


F:\IonicProjects\demoBlank>cordova plugin remove cordova-plugin-inappbrowser --save
Error: Plugin “cordova-plugin-inappbrowser” is not present in the project. See cordova plugin list.

F:\IonicProjects\demoBlank>cordova plugin add cordova-plugin-inappbrowser --save --debug
Error: Failed to fetch plugin cordova-plugin-inappbrowser@1.7.1 via registry.
Probably this is either a connection problem, or plugin spec is incorrect.
Check your connection and plugin name/version/URL.
Error: cmd: Command failed with exit code ENOENT


what should i do now, should i follow the the @Chungtheng steps and downgrade the cordova.
please help

Can you install any plugin via that command?

If you have to get it working, of course you can try to downgrade. But sooner or later you will want to be on the present, supported version.

no i can’t install any plugin vai that command e.g. camera plugin is also giving same error.
whatever the problem is that is with cordova.

Then try the downgrade.

If you use nvm-windows to install node versions, which you should, you can also just install another one and install a different Cordova version there. THen switch back to your normal node version for development.

@Chungtheng, @Sujan12

after downgrading to cordova 6.5.0 i was able to install cordova plugins.

Thanks for the help.

However i think the ionic and cordova team should look into this matter. why that error is only coming in the latest cordova version, there must be some bug in this version(7.0.1) for windows(as i have noticed that MAC or linux users have seldom reported this problem).

Anyway, in near future we will have to switch to latest cordova versions.

The problem is most probably with the new way how plugins are downloaded, via npm. That didn’t exist in 6.5 and npm is prone to strange errors in Windows anyway. Not much they can do - but of course feel free to open an issue at http://issues.cordova.io - only if people report their issues they can even be aware of them.