NPM behind an authenticated proxy

Playing around with npm (Node Package Manager?) needs a little bit of configuration if you are behind an authenticated corpoate proxy. I found myself in this situation while playing with npm at work for the first time. While trying to install some module, npm has shown the following message hinting that proxy configuration is not set.

Image

To resolve this issue, simply configure http/https proxy settings with npm config command

npm config set proxy http://Username:Pa55w0rd@proxyhostname
npm config set https-proxy http://Username:Pa55w0rd@proxyhostname

Being behind an authenticated proxy in a corporate environment increases the probability that you have a very strong password enforced by your IS department. If you have special chars in your password, enclose your Username:Password pair in double quotes as shown in the example below.

npm config set proxy http://"ninjadev:5trongP@ssw0rd"@proxy.some-bigcorp.com
npm config set https-proxy http://"ninjadev:5trongP@ssw0rd"@proxy.some-bigcorp.com

Finally if you wish to verify if the settings are active, verify it by issuing the command

npm config ls *proxy

Image

Advertisements

Android SDK Manager Failing to Load

Android SDK Manager wont open

It’s always a pain in the <you-know-where> when you lose your hard disk to time. Some must be frowning at this statement asking ‘What’s the big deal in this cloud era?’. Well some or most of the data may be somewhere in the skies but getting everything back and setting up one’s development environment to whereever she was, is a real pain as what happened to me few weeks back when I lost my good old HP laptop.

So, I was setting up my Android developement environment on my new laptop with latest available ADT bundle and JDK. But when trying to launch the SDK Manager it was just failing to load and never left a trace of what went wrong. In my case the problem turned out that ADT was unable to locate the private JDK installation. To diagnose, the first thing you can do is to launch a command window, type set JAVA_HOME there, press return key and see if it prints out any directory locations. If it doesn’t, Bingo, thats the deal.

Now, to fix this issue there are two ways, pick the one that suits your level of hackerdome.

  • Option 1 : Set up your JAVA_HOME environment variable from Control Panel > System  and launch SDK Manager (Refer to screenshot below)

env-config

  • Option 2: Modify<sdk-root>\tools\android.bat to point to the required JDK/JRE location as shown below
    • (Here be dragons: Try this only if you have some clue to on how batch files work)
    • Locate the line that says “set java_exe” , assign the path to java.exe,  comment out the next two lines as shown below, save the file and then try launching SDK Manager

android-bat-update

 

TL;DR: Android SDK Manager fails to start without showing any error messages and with possible one single blink of a black window? The ADT has no clue where to locate JDK/JRE on your PC. Either fix your PATH variable to point to a JDK/JRE location or edit <sdk-root>\sdk\tools\android.bat file in the next line where you see the comment ‘Check we have a valid Java.exe in the path’