NPM, BOWER, GIT, and BASH PROXY configurations

Source: Internet
Author: User

Sources: http://digitaldrummerj.me/proxy-configurations/

When you were using NPM, Bower, and git behind a proxy server you had to do a little bit of configuration. Luckily it is a super easy-to-do these configurations. Almost all of the programs has command line commands to set and unset the proxy server.

Updates:
    • Updated 2015-feb-01:added Running Source command for Bash and Ruby Gems sections
    • Updated 2015-may-07:added the Ionic Start command
    • Updated 2015-may-08:added the Android SDK
    • Updated 2015-aug-03:added command lines to set proxy
    • Updated 2015-oct-20:added Gradle
Windows Command promptcurrent command Prompt only
set http_proxy=[Your Proxy]:[Proxy Port]set https_proxy=[Your Proxy]:[Proxy Port]
Unset Current Session
set http_proxy=set https_proxy=
Globally as a System environment Variable

Run from an administrative command prompt

setx http_proxy=[Your Proxy]:[Proxy Port] /Msetx https_proxy=[Your Proxy]:[Proxy Port] /M

You'll need to close and re-open command prompt for settings to take effect

Globally as a User environment Variable

Run from a non-administrative command prompt

setx http_proxy=[Your Proxy]:[Proxy Port] setx https_proxy=[Your Proxy]:[Proxy Port]

You'll need to close and re-open command prompt for settings to take effect

Unset Globally System Environment Variable

Run from an administrative command prompt

setx http_proxy="" /Msetx https_proxy="" /M

Need to close and re-open command prompt for settings to take effect

Unset Globally User Environment Variable

Run from a non-administrative command prompt

setx http_proxy="" setx https_proxy=""

Need to close and re-open command prompt for settings to take effect

View Proxy Settings

If the commands below just echo out the text instead of the actual proxy server, it means that the proxy server was not set .

echo %http_proxy%echo %https_proxy%
Bash Shell

File Name:. Bash_profile or. BASHRC

export http_proxy=[Your Proxy]:[Proxy Port]export https_proxy=[Your Proxy]:[Proxy Port]export npm_config_proxy=[Your Proxy]:[Proxy Port]export npm_config_https_proxy=[Your Proxy]:[Proxy Port]

Note:after updated the. Bash_profile or. BASHRC, you should run one of the following commands to make the configuration a Ctive for the current session.

source ~/.bashrcorsource ~/.bash_profile
Bower

There is no. command line, found for configuring Bower. Instead need to create a. bowerrc file in the users home directory.

On Windows:%userprofile% directory.

On Linux: ~/

Creating. bowerrc file on Windows

Windows Explorer Unfortunately does not allow you to create files without extensions and using Notepad you can create a fi Le without an extension.

    1. Open Notepad
    2. Ctrl + S to save the file
    3. Navigate to the%UserProfile% directory
    4. Change the ' Save as Type ' to ' all Files (.)
    5. Name the file. BOWERRC
    6. Click the Save button
    7. Now you can edit the file in your text editor of choice
Proxy Setting in. BOWERRC.
{"proxy":"http://[Your Proxy]:[Proxy Port]","https-proxy":"http://[Your Proxy]:[Proxy Port]"}
Git

You can also set the proxy settings below to is system wide with The–system switch.

Set Proxy:
git config --add http.proxy http://[Your Proxy]:[Proxy Port]git config --add https.proxy http://[Your Proxy]:[Proxy Port]
Unset Proxy:
git config --unset http.proxygit config --unset https.proxy
View Configuration

Just Proxy configs

git config --get http.proxygit config --get https.proxy

All Configs

git config --list
Manually Update. Gitconfig (not recommended)
[http]proxy = http://[Your Proxy]:[Proxy Port][https]proxy = http://[Your Proxy]:[Proxy Port]
Npmset Proxy:
npm config set https-proxy http://[Your Proxy]:[Proxy Port]npm config set proxy http://[Your Proxy]:[Proxy Port]
Unset Proxy:
npm config delete https-proxynpm config delete proxy
View Proxy Configurations:
npm config get https-proxynpm config get proxy
Manually Update. NPMRC (not recommended)
proxy=http://[Your Proxy]:[Proxy Port]https-proxy=http://[Your Proxy]:[Proxy Port]
Ruby Gem Install

If you had the set the proxy in the. bash_profile or. BASHRC, then Ruby should pick it up.

If you need to manually set it

Linux

Export Http_proxy=[your proxy]:[proxy Port] sudo gem install [Your gem name]

Windows
setx http_proxy "[Your Proxy Server]:[Proxy Port]" /Mgem install [your gem name]
Ionic Start Command

In order to run the Ionic start command behind a proxies, you need start the command out with the proxy information.

Linux
PROXY=http://[Your Proxy]:[Proxy Port] ionic start [App Name] [Template Name]
Windows
setx http_proxy "[Your Proxy Server]:[Proxy Port]" /Mionic start [App Name] [Template Name]
Android SDK

The Android SDK uses ~/.android/androidtool.cfg file to define the proxy information. If The file does not exist, go ahead and create it.

http.proxyHost=[Your Proxy]http.proxyPort=[Proxy Port]
Gradle

When trying to build a Android project that uses Gradle, your may need to configure the proxy for it.

On Windows:%userprofile%/.gradle.properties

systemProp.http.proxyHost=[Your Proxy]systemProp.http.proxyPort=[Proxy Port]systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost    systemProp.https.proxyHost=[Your Https Proxy]systemProp.https.proxyPort=[Https Proxy Port] systemProp.https.nonProxyHosts=*.nonproxyrepos.com|localhost

NPM, BOWER, GIT, and BASH PROXY configurations

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.