解决angular安装 unable to access 'https:github...' Empty reply from server

3,462 阅读1分钟

解决方案:指定https方式,使用代理

错误提示:

    $ npm install
    ......
    bower angular-mocks#1.5.x             ECMDERR Failed to execute "git ls-remote --tags --heads
    https://github.com/angular/bower-angular-mocks.git", exit code of #128 fatal: unable to access
    'https://github.com/angular/bower-angular-mocks.git/': Empty reply from server
    
    Additional error details:
    fatal: unable to access 'https://github.com/angular/bower-angular-mocks.git/': Empty reply from server

分析:这段脚本执行区git拉取代码所用到(默认用ssh)的端口被禁止使用.应该改用https的方式进行下载.

最后在堆栈溢出找到这个方案

    git config --global url."https://".insteadOf git://

再次执行 这个问题没再出现

    $ npm install

ps: 这个https方式有几率会报错

分析:这里是被墙了

错误提示

    $ npm install
    ......
    ECMDERR Failed to execute "git ls-remote --tags --heads
    https://github.com/angular/bower-angular-animate.git", exit code of #128 fatal: unable to access
    'https://github.com/angular/bower-angular-animate.git/': OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054

分析原因还是因为https的方式,撞在了墙上.git默认是不走系统代理的,所以我们需要指定代理来使用https拉取github代码.

解决方案:配置代理

代理配置方法如下(当然啦,最后那个 url 改成自己的代理地址和端口):

    git config --global http.proxy http://127.0.0.1:1080
    git config --global https.proxy https://127.0.0.1:1080

撤销代理:

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

如果要查当前的代理配置,分别是:

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

最后成功运行

    $ npm install
    ......
    angular-resource#1.5.11 app\bower_components\angular-resource
    └── angular#1.5.11
    npm notice created a lockfile as package-lock.json. You should commit this file.
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules\fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted
    {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
    up to date in 106.584s

参考

为 git 设置 http https 代理