reason: Hostname/IP does not match certificate's altnames: Host: registry.cnpmjs.org. is not in the cert's altnames: DNS:r.cnpmjs.org
异常分析
一、今天更新了项目到最新版本后,需要更新一下依赖包,但是使用npm install --save redux
的时候出现问题了
npm install --save redux
npm ERR! code ERR_TLS_CERT_ALTNAME_INVALID
npm ERR! errno ERR_TLS_CERT_ALTNAME_INVALID
npm ERR! request to https://registry.cnpmjs.org/redux failed, reason: Hostname/IP does not match certificate's altnames: Host: registry.cnpmjs.org. is not in the cert's altnames: DNS:r.cnpmjs.org
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\80992399\AppData\Roaming\npm-cache\_logs\2020-06-08T06_53_10_364Z-debug.log
二、之前使用npm install
都是更新成功的,初步判断是连接不到registry.npmjs.org
,因为公司连接到外网需要经过代理的,之前是设置好代理的了,但是有可能代理失效了。
二、一开始以为是代理的问题,因为公司的网络需要设置代理才能连接到外网的,所以重新设置了代理,但是发现没有效果。需要设置代理的卡伊参考这篇文章:https://blog.csdn.net/jim_LoveQ/article/details/106383707
三、在度娘上看到有的说重新配置npm的registry就可以了:
npm config set registry http://registry.npmjs.org
更新了registry之后就可以了
npm install --save redux
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\jest-haste-map\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\watchpack-chokidar2\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\webpack-dev-server\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ redux@4.0.5
added 2 packages from 1 contributor and audited 1682 packages in 12.442s
found 1 low severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details