git is blocked, how to install npm modules

后端 未结 3 1308
感动是毒
感动是毒 2021-01-30 11:18

We are connected through a proxy and here, git is blocked ( not the website but on git//: ) we tried with egit, \"git on windows\", with and without proxy but n

相关标签:
3条回答
  • 2021-01-30 11:39

    The git proxy setting worked for me for cloning repos from github. But, when installing/updating a npm module that uses a git url, I am still getting the timeout error. The workaround for me was to set the proxy manually in the .git/config file for the repo.

    [http]
        proxy = http://proxy.company.com:8888   
    

    But wait, there is more: this worked for some git url but not for other. The second and final workaround was to make sure the git proxy is set in both user config files, since my PC had a shared network user home on I drive:

    I:\.gitconfig
    C:\Users\<userid>\.gitconfig
    

    Credits to this comment.

    0 讨论(0)
  • 2021-01-30 11:47

    Copied from this answer https://stackoverflow.com/a/10729634/1095114


    If this is an issue with your firewall blocking the git: protocol port (9418), then you should make a more persistent change so you don't have to remember to issue commands suggested by other posts for every git repo. This also just works for submodules that might be using the git:// protocol too.

    Simply issue the following command:

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

    This simply adds the following two lines to ~/.gitconfig:

    [url "https://"] insteadOf = git://

    Now, as if by magic, all git commands will perform a substitution of git:// to https://

    0 讨论(0)
  • 2021-01-30 11:58

    Npm and git do not use your Windows proxy settings.

    You can configure them with:

    set HTTP_PROXY=http://user:pass@server.url:port
    

    Also see https://superuser.com/questions/347476/how-to-install-npm-behind-authentication-proxy-on-windows


    If you can't get your proxy working you can run npm install on a machine that has a direct internet connection (e.g. a server in the dmz, at your hosting provider, in the cloud, etc.) and then copy the node_modules folder to your local machine.

    0 讨论(0)
提交回复
热议问题