SSL Error: CERT_UNTRUSTED while using npm command

后端 未结 7 473
梦谈多话
梦谈多话 2020-12-07 08:10

I am trying to install express framework using npm command but getting following error.

error message is

E:\\myFindings\\nodejs_programs\\node>         


        
相关标签:
7条回答
  • 2020-12-07 08:17
    npm ERR! node -v v0.8.0
    npm ERR! npm -v 1.1.32
    

    Update your node.js installation.The following commands should do it (from here):

    sudo npm cache clean -f
    sudo npm install -g n
    sudo n stable
    

    Edit: okay, if you really have a good reason to run an ancient version of the software, npm set ca null will fix the issue. It happened, because built-in npm certificate has expired over the years.

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

    Reinstall node, then update npm.

    First I removed node

    apt-get purge node
    

    Then install node according to the distibution. Docs here .

    Then

    npm install npm@latest -g
    
    0 讨论(0)
  • 2020-12-07 08:18

    I think I got the reason for the above error. It is the corporate proxy(virtual private network) provided in order to work in the client network. Without that connection I frequently faced the same problem be it maven build or npm install.

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

    You can bypass https using below commands:

    npm config set strict-ssl false
    

    or set the registry URL from https or http like below:

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

    However, Personally I believe bypassing https is not the real solution, but we can use it as a workaround.

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

    I had same problem and finally I understood that my node version is old. For example, you can install the current active LTS node version in Ubuntu by the following steps:

    sudo apt-get update
    curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash -
    sudo apt-get install nodejs -y
    

    Installation instructions for more versions and systems can be found in the following link:

    https://github.com/nodesource/distributions/blob/master/README.md

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

    If you're behind a corporate proxy, try this setting for npm with your company's proxy:

    npm --https-proxy=http://proxy.company.com install express -g
    
    0 讨论(0)
提交回复
热议问题