Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding Cordova/Phonegap plugins behind a proxy

I've successfully installed Cordova (clean install, under Windows), and I'm able to deploy a small app to Android, but unable to add any plugins behind my company's proxy. I've already tried setting every possible npm and git variable I could think of via:

npm config set proxy url:port
npm config set http-proxy url:port
npm config set https-proxy url:port

(replaced url:port with the actual proxy) and

git config --system --add http.proxy url:port
git config --global --add http.proxy url:port

but to no avail.

Every time I run something as simple as

cordova plugin add org.apache.cordova.splashscreen

I get the following:

Fetching plugin "org.apache.cordova.splashscreen" via plugin registry
Error: Fetching plugin failed: Error: read ECONNRESET
at C:\Users\x\AppData\Roaming\npm\node_modules\cordova\src\plugin.js:105:41
at _rejected  (C:\Users\x\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:808:24)
at C:\Users\x\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:834:30
at Promise.when (C:\Users\x\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:1079:31)
at Promise.promise.promiseDispatch (C:\Users\x\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:752:41)
at C:\Users\x\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:574:44
at flush (C:\Users\x\AppData\Roaming\npm\node_modules\cordova\node_modules\q\q.js:108:17)
at process._tickCallback (node.js:415:13)

Any help would be much appreciated!

like image 537
white_pawn Avatar asked Feb 27 '14 15:02

white_pawn


3 Answers

The issue can be solved by setting HTTP_PROXY before you run the phonegap command:

set HTTP_PROXY=http://username:password@proxyhost:proxyport

Where your username:password is your login credentials. It's not using the setting in nodejs.

On unix you wouldn't use set.

like image 163
Tom Chamberlain Avatar answered Oct 07 '22 21:10

Tom Chamberlain


One easy way if you don't manage to make git work behind a proxy (sorry I won't be able to help you with that) is to

  • download the git of the plugin using the zip download of git site
  • extract the zip to some path
  • run cordova plugin add pathtotheextractedplugingit

There are several ways to get the url of a plugin git repo, one of them is to go on phonegap build plugin listing page and then click on the plugin you need to get it's url.

For the splash screen plugin it would be https://github.com/apache/cordova-plugin-splashscreen

like image 22
QuickFix Avatar answered Oct 07 '22 20:10

QuickFix


This solution work form me in windows. In your user folder: C:\Users\your_user_name.gradle If exists a file called gradle.properties Edit & add

systemProp.http.proxyHost=[Proxy_IP]
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=[your_username]
systemProp.http.proxyPassword=[your_password]
systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost
systemProp.https.proxyHost=[Proxy_IP]
systemProp.https.proxyPort=8080
systemProp.https.proxyUser=[your_username]
systemProp.https.proxyPassword=[your_password]
systemProp.https.nonProxyHosts=*.nonproxyrepos.com|localhost

If the file does not exists, create it. Replace the text between [] with your right data. Obviously, the [] must be deleted. I left the "proxyPort" with 8080 because is the default in the most of cases.

like image 31
John Torres Barreto Avatar answered Oct 07 '22 20:10

John Torres Barreto