想要在npm上发布自己的组件库,npm登录login时报错:npm ERR! code E401,npm ERR! Incorrect or missing password.
PS D:\Workspace\WebstormProjects\lhqm-ngzorro> npm login
Username: qianmian
Password:
Email: (this IS public) 2515114873@qq.com
npm ERR! code E401
npm ERR! Incorrect or missing password.
npm ERR! If you were trying to login, change your password, create an
npm ERR! authentication token or enable two-factor authentication then
npm ERR! that means you likely typed your password in incorrectly.
npm ERR! Please try again, or recover your password at:
npm ERR! https://www.npmjs.com/forgot
npm ERR!
npm ERR! If you were doing some other operation then your saved credentials are
npm ERR! probably out of date. To correct this please try logging in again with:
npm ERR! npm login
npm ERR! A complete log of this run can be found in:
npm ERR! F:\Program_Files\QianDuan\nodejs\node_cache\_logs\2021-04-04T14_44_24_023Z-debug.log
这是因为之前npm使用了淘宝镜像,淘宝镜像只支持下载,不支持上传发布,需要将配置的registry重新指向npm官方registryhttps://registry.npmjs.org/:
npm config set registry https://registry.npmjs.org/
登录成功:
Logged in as qianmian on https://registry.npmjs.org/.
但是npm官方下载包很慢,再切换到淘宝镜像:
npm config set registry https://registry.npm.taobao.org