NPM login 的时候出错,无法登录,解决

NPM login 的时候出错,无法登录,解决

问题

今天想创建一个 npm 包,结果在登录的时候始终无法登录。
错误提示如下

PS E:\github\calculator-advanced> npm login
npm notice Log in on https://mirrors.cloud.tencent.com/npm/
Username: bingxinke
Password:
Email: (this IS public) kylebing@163.com
npm ERR! code E409
npm ERR! 409 Conflict - PUT https://mirrors.cloud.tencent.com/npm/-/user/org.couchdb.user:bingxinke - user registration disabled

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Administrator\AppData\Local\npm-cache\_logs\2022-03-15T02_11_31_959Z-debug-0.log

原因

应该是你设置过 npm 的源地址,淘宝的或腾讯的,不再是原始的 npm 官方地址
所以登录的时候就无法登录了
一个简单的方法设置 npm 源,使用 nrm

nrm 是一个管理 npm 镜像地址的工具,可以通过它来改变 npm 镜像源地址

1. 安装 nrm

sh-3.2# npm i -g nrm
npm WARN deprecated coffee-script@1.7.1: CoffeeScript on NPM has moved to "coffeescript" (no hyphen)
/usr/local/bin/nrm -> /usr/local/lib/node_modules/nrm/cli.js
+ nrm@1.1.0
added 324 packages from 564 contributors in 22.77s

2. 查看可用的 npm 源地址

sh-3.2# nrm ls

* npm ---- https://registry.npmjs.org/
  cnpm --- http://r.cnpmjs.org/
  taobao - https://registry.npm.taobao.org/
  nj ----- https://registry.nodejitsu.com/
  npmMirror  https://skimdb.npmjs.com/registry/
  edunpm - http://registry.enpmjs.org/

3.设置 npm 地址

将 npm 地址设置成官方源地址即可

  λ nrm use npm
   Registry has been set to: https://registry.npmjs.org/

结果

设置完成之后就能正常登录了,这里我已经设置了 2FA 两步验证。官方说明: https://docs.npmjs.com/configuring-two-factor-authentication
1. List item

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

十月ooOO

许个愿,我帮你实现

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值