最近在写一个npm包时,需要登陆npm,于是乎执行npm login 输入账号密码邮箱,但发现一直都登陆不了,查了下发现是npm 源不对,想了想好像是的,目前一直使用的是淘宝源,所以需要把镜像切回来,这个时候就用到了以前一直不怎么用的nrm --- 快速切换npm源神奇。
使用步骤:
-
npm install -g nrm全局安装 -
nrm ls查看目前使用的源情况,淘宝源没错了
npm -------- https://registry.npmjs.org/
yarn ------- https://registry.yarnpkg.com/
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/
- 需要把它切回到npm 源,但怎么切回去呢?
nrm -h(i need help)
$ nrm -h
Usage: cli [options] [command]
Options:
-V, --version output the version number
-h, --help output usage information
Commands:
ls List all the registries
current Show current registry name
use <registry> Change registry to registry
add <registry> <url> [home] Add one custom registry
set-auth [options] <registry> [value] Set authorize information for a custom registry with a base64 encoded string
or username and pasword
set-email <registry> <value> Set email for a custom registry
set-hosted-repo <registry> <value> Set hosted npm repository for a custom registry to publish packages
del <registry> Delete one custom registry
home <registry> [browser] Open the homepage of registry with optional browser
publish [options] [<tarball>|<folder>] Publish package to current registry if current registry is a custom registry. if you're not using custom registry, this command will run npm publish directly
test [registry] Show response time for specific or all registries
help Print this help
哟 找到了,use <register>,
nrm use npm
Registry has been set to: https://registry.npmjs.org/ 切换成功
nrm ls来看看目前源情况
* npm -------- https://registry.npmjs.org/
yarn ------- https://registry.yarnpkg.com/
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/
没错了,再执行npm login,登陆成功。