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

When you are using npm, bower, and git behind a proxy server you have to do a little bit of configuration. Luckily it is super easy to do these configurations. Almost all of the programs have command line commands to set and unset the proxy server.

Updates:

  • Updated 2015-Feb-01: Added running source command for Bash and Ruby Gems section
  • 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 Prompt

Current 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] /M
setx https_proxy=[Your Proxy]:[Proxy Port] /M

You will 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 will 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="" /M
setx 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 is 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 active for the current session.

source ~/.bashrc
or
source ~/.bash_profile

Bower

There is no command line that I found for configuring bower. Instead you 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 but using notepad you can create a file 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 be 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]

git config --global http.proxy 'socks5://127.0.0.1:3128'

git config --global https.proxy 'socks5://127.0.0.1:3128'

Unset Proxy:

git config --unset http.proxy
git config --unset https.proxy

View Configuration

Just Proxy Configs

git config --get http.proxy
git 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]

NPM

Set 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-proxy
npm config delete proxy

View Proxy Configurations:

npm config get https-proxy
npm 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 have 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]" /M
gem install [your gem name]

Ionic Start Command

In order to run the ionic start command behind a proxy, 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]" /M
ionic 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 an Android project that uses Gradle, you 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的更多相关文章

  1. windows下nodejs+npm+bower+git+bootstrap组件环境配置

    1.进入nodejs官方网站下载软件(nodejs.org), 2.下载完成后,双击默认安装.安装程序会自动添加环境变量 3.检测nodejs是否安装成功.打开cmd命令行 输入 node - v 显 ...

  2. 创建 Web 前端开发环境(node和npm以及git)

    Web 前端开发涉及多种工具,这里将常用工具的安装和配置进行说明,提供了详细的说明,为后继的开发创建一个坚实的基础. 本文介绍的工具有:NodeJS, NPM, Bower, Git 和 Grunt. ...

  3. npm和git代理

    npm 删除代理设置:npm config delete proxynpm config delete https-proxynpm 设置代理:npm config set proxy http:// ...

  4. ubuntu14.04下nodejs + npm + bower的安装、调试和部署

      1. 简介 本文介绍ubuntu14.04下nodejs+npm+bower的安装.调试和部署 参考文档 https://docs.npmjs.com/getting-started https: ...

  5. NET Core 静态文件及JS包管理器(npm, Bower)的使用

    NET Core 静态文件及JS包管理器(npm, Bower)的使用 文章目录 在 ASP.NET Core 中添加静态文件 使用npm管理JavaScript包 使用Bower管理JavaScri ...

  6. 用npm安装git上的项目

    直接通过 git 上项目的地址进行安装npm install git+https://github.com/sunxiaochuan/koatest.git 地址获取如下图:

  7. 关于Idea里设置Terminal为Git/bin/bash.exe中文乱码的问题的终极解决方案

    1.这里如果设置为Git/git-bash.exe确实不会乱码,但是每次点Idea里的Terminal都会弹出一个单独的terminal窗口而非在idea子窗口里出现: 2.因此需要设置为Git/bi ...

  8. CMD & Git Shell & Bash Shell

    CMD & Git Shell & Bash Shell https://mvdan.cc/sh/cmd/shfmt PC

  9. 问题:bower git is not installed or not in the path

    用bower install jquery安装jquery,bower提示错误bower git is not installed or not in the path. 根据错误信息的知道出现错误两 ...

随机推荐

  1. MATLAB读取写入文本数据最佳方法 | Best Method for Loading & Saving Text Data Using MATLAB

    MATLAB读取文件有很多方法.然而笔者在过去进行数据处理中,由于函数太多,相互混杂,与C#,Python等语言相比,反而认为读取文本数据比较麻烦.C#和Python等高级语言中,对于大部分的文本数据 ...

  2. Oracle 写存储过程的一个模板还有一些基本的知识点

    我很少用Oracle,也算新手,不过其实入手没有那么难,下面只是一个基本知识,高手绕道,其实数据库基本是相同的,这里提供都是基本知识点 有一个Oracle溢出的问题,容易让新手怀疑到无所怀疑,其实就是 ...

  3. 迷宫救人——DFS小题

    原创 题目大意:人质被困在迷宫之中,要求你寻找一条最短路径快速找到人质. 如图,人质在黄色点2处,营救者在起点红色处,1表示无法通过的障碍点,寻找一条最短路径快速找到人质. 毫无疑问用DFS,遍历4个 ...

  4. MongoDB整理笔记の管理Sharding

    1.列出所有的Shard Server > db.runCommand({ listshards: 1 }) --列出所有的Shard Server { "shards" : ...

  5. 用原生css实现高斯模糊、黑白等滤镜效果

    —引导— 在CSS3中,有一个强大的属性,那就是filter属性,filter顾名思义就是“滤镜”的意思,用filter属性可以让图片无需PS处理就达到一些简单的显示效果. —定义和使用— filte ...

  6. 2张图简单分析count(0)与count(*)

    以前一直以为count(0)查询效率比count(*)比较高,原因大概是这么认为count(0)只是第一列进行统计,而count(*)所有列放在一起统计(亲,不要误会,这里不是所有列累加哦) 结果真的 ...

  7. 独立线程监控配置文件是否变更,适用于更新了配置文件,不需要重启tomcat服务

    直接贴出来代码: package cn.leadeon.utils.file; import java.io.File; import java.io.FileInputStream; import ...

  8. c++迭代递归实现汉诺塔(5种迭代方法满足你)

    #include <iostream> //从A到C using namespace std; int n; void ready() { cout << "请输入汉 ...

  9. Can't install Solaris 10 on XenServer 6.5 VM

    I have XenServer 6.5 installed on a server, and i have been trying to install Solaris 10 on a VM, it ...

  10. jmeter函数助手(_random、_time)

    jmeter函数助手 __random __time yyyyMMddHHmmdd  时间格式(年月日时分秒) 1.打开函数助手对话框,选项->函数助手对话框 2.生成函数字符串 (1)选择功能 ...