npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY

前端 未结 10 1372
心在旅途
心在旅途 2020-12-07 07:50

I am trying all the ways of creating react application. I have tried with maven and now i am trying with crate-react-app build system from Facebook Incubators.

When

相关标签:
10条回答
  • 2020-12-07 08:31

    Trust me, this will work for you:

        npm config set registry http://registry.npmjs.org/  
    
    0 讨论(0)
  • 2020-12-07 08:35

    Changing the NPM repo URL to HTTP works as a quick-fix, but I wanted to use HTTPS.

    In my case, the proxy at my employer (ZScaler) was causing issues (as it acts as a MITM, causing certification verification issues)

    I forgot I found a script that helps with this and Git (for cloning GitHub repos via HTTPS had the same issue) and forked it for my use

    Basically, it does the following for git:

    git config --global http.proxy http://gateway.zscaler.net:80/
    git config --system http.proxy http://gateway.zscaler.net:80/
    

    and for Node, it adds proxy=http://gateway.zscaler.net:80/ to the end of c:\Users\$USERNAME\npm\.npmrc

    That solved the issue for me.

    0 讨论(0)
  • 2020-12-07 08:35

    In my case, at some point I set my global config to use a cert that was meant for a project.

    npm config list

    /path/to/global/.npmrc
    NODE_EXTRA_CA_CERTS = "./certs/chain.pem"
    

    I opened the file, removed the line and npm install worked again.

    0 讨论(0)
  • 2020-12-07 08:39

    A quick solution from the internet search was npm config set strict-ssl false, luckily it worked. But as a part of my work environment, I am restricted to set the strict-ssl flag to false.

    Later I found a safe and working solution,

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

    this worked perfectly and I got a success message Happy Hacking! by not setting the strict-ssl flag to false.

    0 讨论(0)
  • 2020-12-07 08:40

    After trying out every solution I could find:

    • Turning off strict ssl: npm config set strict-ssl=false
    • Changing the registry to http instead of https: npm config set registry http://registry.npmjs.org/
    • Changing my cafile setting: npm config set cafile /path/to/your/cert.pem
    • Stop rejecting unknown CAs: set NODE_TLS_REJECT_UNAUTHORIZED=0

    The solution that seems to be working the best for me now is to use the NODE_EXTRA_CA_CERTS environment variable which extends the existing CAs rather than replacing them with the cafile option in your .npmrc file. You can set it by entering this in your terminal: NODE_EXTRA_CA_CERTS=path/to/your/cert.pem

    Of course, setting this variable every time can be annoying, so I added it to my bash profile so that it will be set every time I open terminal. If you don’t already have a ~/.bash_profile file, create one. Then at the end of that file add export NODE_EXTRA_CA_CERTS=path/to/your/cert.pem. Then, remove the cafile setting in your .npmrc.

    0 讨论(0)
  • 2020-12-07 08:40

    Had the same error. Looks like it is related to SSL certificates. If you are using NPM for public packages (don't need the security of HTTPS) you can turn off strict SSL key validation with the following command.

    This might be the simplest fix if you're just looking to install a few publicly available packages one time.

    npm config set strict-ssl=false
    
    0 讨论(0)
提交回复
热议问题