npm behind a proxy fails with status 403

前端 未结 9 1151
野趣味
野趣味 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 08:04
    npm config set proxy http://proxy.company.com:8080
    npm config set https-proxy http://proxy.company.com:8080
    

    credit goes to http://jjasonclark.com/how-to-setup-node-behind-web-proxy.

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

    If anyone else ends up breaking their proxy config settings go to your .npmrc, to type in the settings. This file is located at your node root folder level.

    Here's whats my corrected file looks like:

    #proxy = http://proxy.company.com:8080
    https-proxy = https://proxy.company.com:8080 
    registry = http://registry.npmjs.org/
    
    0 讨论(0)
  • 2020-12-04 08:11

    For those using Jenkins or other CI server: it matters where you define your proxies, especially when they're different in your local development environment and the CI environment. In this case:

    • don't define proxies in project's .npmrc file. Or if you do, be sure to override the settings on CI server.
    • any other proxy settings might cause 403 Forbidden with little hint to the fact that you're using the wrong proxy. Check your gradle.properties or such and fix/override as necessary.

    TLDR: define proxies not in the project but on the machine you're working on.

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