cordova platform add – TypeError: Request path contains unescaped characters
Hello everybody.
This error occurs when this conditions are met:
- You have node -v greater than 0.11.x (probably 0.12.x)
- You are behind a proxy (probably your company’s)
- You are using cordova-cli (that’s my guess, but it’s the same with ionic-cli)
The solution was not that easy to find on google, most of the people just treated it as a bug waiting to be fixed, but actually you can get your ‘cordova platform add’ in few seconds with these commands:
- Analyse your request. Based on what you are trying to “cordova platform add [platform-name]” you are trying to retrieve a plugin. You should fin an url in the command line error like:
$ cordova platform add android npm http GET https://registry.npmjs.org/cordova-android/4.0.0 TypeError: Request path contains unescaped characters. ...
- Visit the url https://registry.npmjs.org/cordova-android/4.0.0 and you will find a JSON. At the end of the JSON you should find these lines:
"dist":{ "shasum":"6a268b3....bc7f9ef6e6c1", "tarball":"http://registry.npmjs.org/cordova-android/-/cordova-android-4.0.0.tgz" }
Get that tarball!
-
Untar your tarball in any folder you want. Then from cordova just type:
cordova platform add /path/to/your/tarball/extracted/folder
Voilà! Cordova will add the platform as it was a “cordova platform add android” command. You can now run your build, emulate and run commands normally.
PS: Of course this is not a permanent fix, but a quick workaround.
Good luck!
Great help, thanks!!
Here, I am gettting issue: the provided path does not seem to contain a cordova platform.
I think the part you are providing is not correct or the platform inside it is not compatible with the current cordova version. The tutorial was made using version `4.0.0`. It can be different if your version is `5.0.0` (run in the terminal `cordova -v`)