Node.JS module install behind a corporate proxy

If you happen to be behind a corporate firewall like me, chances are you have tons of problems with Node’s package manager,npm.

So here are some steps which might help you.

1. Setup NPM to use your proxy configuration

sudo npm config set proxy http://proxy.mycompany.comg:3128
sudo npm config set https-proxy https://proxy.mycompany.com:3128

2. Force your npm to use HTTP over HTTPS
You could do this by doing :


sudo npm config set registry http://registry.npmjs.org/

 

The above steps should work for majority of modules but it may not work for some.

3. If the module has a HTTPS reference explicitly in its package.json dependencies
Some modules specify the full URL in their dependencies other than just the name. If that is the case NPM would go and fetch the module from that URL . If the URL contains HHTPS although you have specified to use HHTP only but it would try to access HTTPS, so it would freeze there specially if your proxy server blocks that.

In this case:
3.1 Clone the repository to your local machine

3.2 Modify the package.json file and replace any HTTPS with HTTP

3.3 Install the local module
To install the module located in your local hard drive, use NPM and instead of module’s name, specify the path:


npm install module/

 

This should fix most of the issues with installing a module behind a corporate proxy.

Advertisements

Extending VirtualBoxes Virtual hard Drive

I usually have one Windows available in hand in a VM. Knowing windows, it would eat all the hard drive you dedicate to it. So at the setup time I decided to give it a flexible size but maximum of 25GB, which seemed fair for Windows 7. But now that I have had it for a while it got quite big and when I wanted to install a new application, I was running out of space.

Extending an existing drive is not possible, but the whole process to achieve what’s needed is very very simple. All you need to is:

  1. Go to VM’s setting / storage and create a new bigger storage, which would be your only HDD
  2. clone the hard drive from the old one to the new one. Here is the VirtualBox’s command:
    $VBoxManage  clonehd /Path/to/old/Windows7.vdi  /path/to/new/Win7_30GB.vdi --existing
  3. Now remove the HDD from your existing VM. (VM/Setting/Storage)
  4. Add your new HDD to the VM.
  5. Boot the VM
  6. In the guest OS, go to “Control Panel/ Administrative Tools/ Computer Management/ Storage”   and you should be able to see the extra space as unallocated. Just extend the existing drive to the maximum to use it

Enjoy your extended HDD.