NodeJS NPM Proxy error when installing grunt

后端 未结 11 1894
太阳男子
太阳男子 2020-12-25 13:58

When I\'m trying to install grunt via npm, I\'m getting a following error:

C:\\Program Files\\nodejs\\node_modules\\npm>npm inst         


        
相关标签:
11条回答
  • 2020-12-25 14:48

    Below options made it work for me:

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

    npm config set proxy http://user:password@proxy.url.com:proxy-port

    npm config set strict-ssl false

    npm install -g -d yo

    0 讨论(0)
  • 2020-12-25 14:52

    This configuration works for me. You need to check your http and https ports (usually they are 80 and 443 respectively), but in my case I am using port 80 for both.

    npm config set proxy http://user:password@proxy.url.com:80
    
    npm config set https-proxy http://user:password@proxy.url.com:80
    

    You can check your proxy settings by get command

    npm config get proxy
    
    npm config get https-proxy
    
    0 讨论(0)
  • 2020-12-25 14:53

    If you are working behind a proxy in a "windows" domain, add the domain name into the proxy url:

    npm config set proxy http://domain%5Cuser:password@proxy.company.com:8080
    npm config set https-proxy http://domain%5Cuser:password@proxy.company.com:8080
    

    You need to encode the backslash as a http uri string: %5C

    If there are special characters in your username or password, it is necessary to encode these character as well. Keep in mind that these critical informations are stored as plain text in the npm config file (%HOME%\.npmrc). It could also be necessary to point the npm registry to the http source:

    npm config set registry "http://registry.npmjs.org"
    npm config set strict-ssl false
    
    0 讨论(0)
  • 2020-12-25 14:54

    I had same issue before because I played with proxy configuration by mistake like this :

    npm config set proxy http://localhost:8080/ npm config set https-proxy http://localhost:8080/ npm config set strict-ssl false

    which made npm client attempts to hit localhost:8080 to pull the module rather than the correct internet endpoint.

    so after couple of days of frustration i found this link https://docs.npmjs.com/cli/config

    which tells you to run

     npm config edit
    

    That opened a file, inside that file i removed those three lines i added above , and yes, everything worked fine. ALH Hope that helps.

    0 讨论(0)
  • 2020-12-25 14:55

    You need to configure the npm config file, this can be done in the terminal:

    npm config set proxy http://proxy.company.com:8080
    
    npm config set https-proxy http://proxy.company.com:8080
    

    Your error log suggests to see 'npm help config', so i think the problem comes from there.

    If you want a link with more explanation see this blog entry (there are plenty more)

    Good luck!

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