npm behind a proxy fails with status 403

前端 未结 9 1150
野趣味
野趣味 2020-12-04 07:24

I\'m trying to run npm behind a proxy. I\'ve tried both entering the proxy directly or through Authoxy:

npm config set proxy http://localho         


        
相关标签:
9条回答
  • 2020-12-04 07:47

    I had the same issue and finally it was resolved by disconnecting from all VPN .

    0 讨论(0)
  • 2020-12-04 07:55

    OK, so within minutes after posting the question, I found the answer myself here: https://github.com/npm/npm/issues/2119#issuecomment-5321857

    The issue seems to be that npm is not that great with HTTPS over a proxy. Changing the registry URL from HTTPS to HTTP fixed it for me:

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

    I still have to provide the proxy config (through Authoxy in my case), but everything works fine now.

    Seems to be a common issue, but not well documented. I hope this answer here will make it easier for people to find if they run into this issue.

    0 讨论(0)
  • 2020-12-04 07:56

    Due to security violations, organizations may have their own repositories.

    set your local repo as below.

    npm config set registry https://yourorg-artifactory.com/

    I hope this will solve the issue.

    0 讨论(0)
  • 2020-12-04 07:58

    If you need to provide a username and password to authenticate at your proxy, this is the syntax to use:

    npm config set proxy http://usr:pwd@host:port
    npm config set https-proxy http://usr:pwd@host:port
    
    0 讨论(0)
  • 2020-12-04 07:58

    On windows 10, do

    npm config edit
    

    This will open config file in a text editor. Delete all the set proxy variables by user and only let default values stay.

    ;;;;
    ; npm userconfig file
    ; this is a simple ini-formatted file
    ; lines that start with semi-colons are comments.
    ; read `npm help config` for help on the various options
    ;;;;
    
    --->Delete everything proxy settings from here.
    
    ;;;;
    ; all options with default values
    ;;;;
    

    Close and save. Try again. That's what worked for me in my localhost.

    0 讨论(0)
  • 2020-12-04 08:00

    On windows10, create this file. Worked for me.

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