NPM, BOWER, GIT, AND BASH PROXY CONFIGURATIONS
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.
- Open Notepad
- Ctrl + S to save the file
- Navigate to the %UserProfile% directory
- Change the “Save as Type” to “All Files (.)
- Name the file .bowerrc
- Click the Save button
- 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的更多相关文章
- windows下nodejs+npm+bower+git+bootstrap组件环境配置
1.进入nodejs官方网站下载软件(nodejs.org), 2.下载完成后,双击默认安装.安装程序会自动添加环境变量 3.检测nodejs是否安装成功.打开cmd命令行 输入 node - v 显 ...
- 创建 Web 前端开发环境(node和npm以及git)
Web 前端开发涉及多种工具,这里将常用工具的安装和配置进行说明,提供了详细的说明,为后继的开发创建一个坚实的基础. 本文介绍的工具有:NodeJS, NPM, Bower, Git 和 Grunt. ...
- npm和git代理
npm 删除代理设置:npm config delete proxynpm config delete https-proxynpm 设置代理:npm config set proxy http:// ...
- ubuntu14.04下nodejs + npm + bower的安装、调试和部署
1. 简介 本文介绍ubuntu14.04下nodejs+npm+bower的安装.调试和部署 参考文档 https://docs.npmjs.com/getting-started https: ...
- NET Core 静态文件及JS包管理器(npm, Bower)的使用
NET Core 静态文件及JS包管理器(npm, Bower)的使用 文章目录 在 ASP.NET Core 中添加静态文件 使用npm管理JavaScript包 使用Bower管理JavaScri ...
- 用npm安装git上的项目
直接通过 git 上项目的地址进行安装npm install git+https://github.com/sunxiaochuan/koatest.git 地址获取如下图:
- 关于Idea里设置Terminal为Git/bin/bash.exe中文乱码的问题的终极解决方案
1.这里如果设置为Git/git-bash.exe确实不会乱码,但是每次点Idea里的Terminal都会弹出一个单独的terminal窗口而非在idea子窗口里出现: 2.因此需要设置为Git/bi ...
- CMD & Git Shell & Bash Shell
CMD & Git Shell & Bash Shell https://mvdan.cc/sh/cmd/shfmt PC
- 问题: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. 根据错误信息的知道出现错误两 ...
随机推荐
- JAVA的String 类【转】
String类 1.String对象的初始化 由于String对象特别常用,所以在对String对象进行初始化时,Java提供了一种简化的特殊语法,格式如下: String s = “abc”; s ...
- 【C#】is 和 as
看个例子: public class User { } public class Group { } class Program { static void Main(string[] args) { ...
- Java Serializable(序列化)的理解和总结
1.序列化是干什么的? 简单说就是为了保存在内存中的各种对象的状态(也就是实例变量,不是方法),并且可以把保存的对象状态再读出来.虽然你可以用你自己的各种各样的方法来保存object st ...
- 【SQL】- 基础知识梳理(五) - 触发器
触发器的概念 触发器对表进行插入.更新.删除的时候会自动执行的特殊存储过程 触发器的语法 create trigger tgr_name on table_name with encrypion –加 ...
- Castle Windsor
让我们从Web API的集成点开始,它们是IDependencyResolver和IDependencyScope接口.IDependencyResolver和其他接口的名称可能与MVC中的接口相同, ...
- CHNetRequest网络请求
Paste JSON as Code • quicktype 软件的使用 iOS开发:官方自带的JSON使用 JSON 数据解析 XML 数据解析 Plist 数据解析 NetRequest 网络数据 ...
- Size Assertion
Size Assertion每一个响应包含的字节大小,可以设置大小等于,大于,小于,不等于给定的字节数. Apply to:应用范围,一般勾选Main samle only即可. Response S ...
- windows如何通过端口查看对应程序
今天打开SSR报错,说端口被占用. 打开的软件有点多,又不想重启.就需要找到占用的软件,关闭了即可. 打开cmd,输入netstat -aon能看到所有的使用端口 其中1080端口是预留给SSR使用的 ...
- 【BZOJ2159】Crash的文明世界 斯特林数+树形dp
Description Crash 小朋友最近迷上了一款游戏--文明5(Civilization V).在这个游戏中,玩家可以建立和发展自己的国家,通过外交和别的国家交流,或是通过战争征服别的国家.现 ...
- 【BZOJ1853】[Scoi2010]幸运数字 容斥原理+搜索
Description 在中国,很多人都把6和8视为是幸运数字!lxhgww也这样认为,于是他定义自己的"幸运号码"是十进制表示中只包含数字6和8的那些号码,比如68,666,88 ...