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.

  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]

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
时间: 2024-10-11 04:12:31

NPM, BOWER, GIT, AND BASH PROXY CONFIGURATIONS的相关文章

Nodejs+NPM+Bower+Git~+~ionic+Java JDK+Apache Ant+Android SDK,安装及配置环境

1.下载和安装nodejs. 可以通过官网下载,不过由于墙及国外网络等原因,可能下载缓慢.也可以通过国内中文站,以及百度搜索国内一些网站下载文件.安装NODEJS,下一步默认安装成功就可以了, V4.4.7老版本成熟稳定可靠,菜鸟或商业环境建议老版本,也可以去官网下载最新版本,官网:https://nodejs.org/en/      中文网:http://nodejs.cn/ 安装过程基本直接"NEXT"就可以了.(windows的安装msi文件在过程中会直接添加path的系统变量

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

  1. 简介 本文介绍ubuntu14.04下nodejs+npm+bower的安装.调试和部署 参考文档 https://docs.npmjs.com/getting-started https://github.com/npm/npm/issues/ 另外: Windows nodejs版本https://nodejs.org/download/release/latest/node-v5.5.0-x64.msi Windows下ide可选用WebStorm-10.0.2.exe 2.  

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

NET Core 静态文件及JS包管理器(npm, Bower)的使用 文章目录 在 ASP.NET Core 中添加静态文件 使用npm管理JavaScript包 使用Bower管理JavaScript包 在 ASP.NET Core 中添加静态文件 虽然ASP.NET主要大都做着后端的事情,但前端的一些静态文件也是很重要的.在ASP.NET Core中要启用静态文件,需要Microsoft.AspNetCore.StaticFiles组件.可以通过Nuget添加,或者在project.jso

Using NpUsing Npm Behindm Behind a Corporate Proxy

On a recent assignment, I needed to install npm behind a corporate proxy. I had already set the environment variables HTTP_PROXY and HTTPS_PROXY. Other command line utilities, like ruby gems, recognized these environment variables. Npm did not. After

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

1.这里如果设置为Git/git-bash.exe确实不会乱码,但是每次点Idea里的Terminal都会弹出一个单独的terminal窗口而非在idea子窗口里出现: 2.因此需要设置为Git/bin/bash.exe,但是这个东西它本质上貌似是用Cmd.exe来打开的?(反正需要设置页编码为65001),而且坑爹的还是它不支持chcp命令,不然还能设置AutoRun chcp 65001: 最终找了一个下午,终于在注册表里看到了改变方法,在注册表:HKEY_CURRENT_USER/Cons

用npm安装git上的项目

直接通过 git 上项目的地址进行安装npm install git+https://github.com/sunxiaochuan/koatest.git 地址获取如下图: 原文地址:https://www.cnblogs.com/longailong/p/10531692.html

npm 关联 git包

npm 关联 git包 由于现在项目越做越多,很多公共的部分相互公用,需要尽可能早地提炼出来,这样便可以在其他项目进行引用,而不是每次建一个项目就需要进行拷贝,这样太痛苦了,因而想通过类似npm包管理来进行处理 npm 包 初始化一个项目 定义 package.json version 版本(注意书写格式,若是报 invalid version, 便需要审查下了) main 用来定义文件地址,用来对外公开的 其他项目关联包 npm package-name: git地址 git地址定位具体的分支

NodeJS+NPM+Bower+Android环境安装配置

一. 安装nodejs与npm 1. **安装nodejs:**进入官网[https://nodejs.org/](https://nodejs.org/ "https://nodejs.org/")下载安装包安装,一路next,安装后进入cmd,输入`node -v`,出现版本号说明安装成功. 2. **安装npm:**最新的nodejs已集成npm,输入`npm -v`出现版本号说明安装成功. - **配置npm的"全局模块"与"缓存"路径*

npm和git使用

使用方法在gitlab上先复制http的链接然后打开git bash here输入git clone 然后右键paste复制 -b develop 复制下来之后,打开命令行工具npm install淘宝镜像npm install --registry=https://registry.npm.taobao.orgnpm run dev 上传文件$ git add .$ git commit -m "改动的地方提示"$ git push 如果有人新上传了东西$git pull 原型htt