Dev Trouble Shooting

Published on

item2 设置代理

修改 .zshrc文件,source ~/.zshrc 生效.

  • socks5 方式
alias proxys5='export ALL_PROXY=socks5://127.0.0.1:1080'
alias unproxys5='unset ALL_PROXY'
  • http 方式
alias proxyhp='export http_proxy=http://127.0.0.1:7890;export https_proxy=http://127.0.0.1:7890;'
alias unproxyhp='unset http_proxy https_proxy'

执行 proxyhp 终端代理,执行 unproxyhp 关闭。

针对于命令行的,一般用 http 方式。另外 git 的需要单独设置。

Configuring iTerm and Git to use a proxy on OS X:

https://stackoverflow.com/questions/5137852/configuring-iterm-and-git-to-use-a-proxy-on-os-x

How do I pull from a Git repository through an HTTP proxy?

https://stackoverflow.com/questions/128035/how-do-i-pull-from-a-git-repository-through-an-http-proxy

git 命令行设置代理

git config --global http.proxy http://proxy.mycompany:80

设置 git 使用 socks5 代理

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

ssh 代理:

修改 ~/.ssh/config 文件

Host github.com
    User git
    ProxyCommand nc -v -x 127.0.0.1:1086 %h %p

Git ssh:https://gist.github.com/chenshengzhi/07e5177b1d97587d5ca0acc0487ad677

npm 设置代理

注意区别于换源,代理的作用是加了个请求中间人。

npm config set proxy http://127.0.0.1:7890
npm config set https-proxy http://127.0.0.1:7890

npm config delete proxy
npm config delete https-proxy

换源:

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

换源一般用 nrm 工具:https://github.com/Pana/nrm

Mac 修改 host

vim /etc/hosts

host 为 readonly 的时候 :wq会报错: E45 readonly option is set (add ! to override)

press Esc , and then U , and then type :q .

需要加上 sudo 去编辑 :

sudo vi /etc/hosts