今天想到 npm 上发个包,结果报错 E426。
npm ERR! code E426
npm ERR! 426 Upgrade Required - PUT http://registry.npmjs.org/nf-state
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\jyk00\AppData\Local\npm-cache\_logs\2021-10-08T04_52_56_113Z-debug.log
各种尝试还是报错,各种搜索终于找到原因。
npm 升级 到 TLS1.2,不接受 TLS 1.1\1.0了。
那么没关系,升级呗,查了一下,需要升级本地的npm,升级到v7就行。
但是,我都升级到npm v8了,node都升级到 v16,结果还是不行。
真的好无语。
验证 是否支持 TLS1.2
npm install -g https://tls-test.npmjs.com/tls-test-1.0.0.tgz
结果是不支持。
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/
返回这个才是支持
Hello! The tls-test package was successfully downloaded and installed.
Congratulations! Your package manager appears to support TLS 1.2.
除了升级本地npm之外,还需要做什么设置?
不知道还差哪。。。
不过,发现直接把包放到 node_modules 里就可以用了,如果还解决不了的话,就只好手动了。
====================更新---------------------
终于找到原因了,修改镜像的时候需要使用 https
npm config set registry=https://registry.npmjs.org
就差个s。。。