如果npm login 的时候遇到如下错误
npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/
npm notice Beginning October 4, 2021, all connections to the npm registry - including for package installation - must use TLS 1.2 or higher. You are currently using plaintext http to connect. Please visit the GitHub blog for more information: https://github.blog/2021-08-23-npm-registry-deprecating-tls-1-0-tls-1-1/
类似的提示TlS错误的时候。可以看看自己的源是不是设置成http的了。因为现在npm login必须要通过Https了。可以用
npm config get registry
这个命令来查看当前的源。如果是http开头,或者不是
https://registry.npmjs.org/ 这个源的话(如果不是这个源。可能会报其他错误。类似403之类的错误码)
就使用
npm config set registry https://registry.npmjs.org
来设置源。然后再登录就可以了。