安装npm包的时候出现unable to get local issuer certificate的错误解决办法

我本地的npm是通过node.js安装包安装之后来的,在安装有些npm包的时候很正常,但是当我安装superagent时出错了,具体的错误信息如下:

npm ERR! Windows_NT 6.1.7601
npm ERR! argv "H:\\e\\Program Files\\nodeJs\\node.exe" "H:\\e\\Program Files\\nodeJs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save-dev" "superagent"
npm ERR! node v6.9.1
npm ERR! npm  v3.10.8
npm ERR! code UNABLE_TO_GET_ISSUER_CERT_LOCALLY

npm ERR! unable to get local issuer certificate
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     H:\g\webTest\nodeTest\npm-debug.log

在多次排查之后,依然毫无头绪。通过在npm项目issue中发现有同样问题,发现执行下面语句即可:

npm config set strict-ssl false 

或者在主目录下的.npmrc文件中修改strict-ssl等于false

参考:

  • https://github.com/npm/npm/issues/14667
  • https://docs.npmjs.com/misc/config

你可能感兴趣的:(Node.js)