问题:使用vscode安装Router依赖资源时遇到Bug报错:
npm error code E451
npm error 451 Unavailable For Legal Reasons - GET https://registry.npmmirror.com/- - [UNAVAILABLE_FOR_LEGAL_REASONS] - was
blocked, reason: ucc (operator: cnpmcore_admin/61f154594ce7cf8f5827edf8)
npm error A complete log of this run can be found in...
解决方法:使用 nrm 工具切换源
nrm
是一个 npm
源管理工具,可以方便地在不同的 npm
源之间进行切换。
1.安装 nrm
先通过以下命令安装 nrm
:
npm install -g nrm
注意这里使用了 -g
参数,表示全局安装,安装完成后就可以在命令行的任意位置使用 nrm
命令了。
2.查看可用源
执行以下命令查看当前可用的 npm
源列表:
nrm ls
你会看到类似如下输出,其中包含了如 npm
(默认源)、taobao
(淘宝源)、cnpm
等多个源:
* npm ---- https://registry.npmjs.org/
yarn --- https://registry.yarnpkg.com/
cnpm --- https://r.cnpmjs.org/
taobao - https://registry.npm.taobao.org/
nj ----- https://registry.nodejitsu.com/
npmMirror https://skimdb.npmjs.com/ry
edunpm https://registry.enpmjs.org/
前面带有 *
号的表示当前正在使用的源。
3.切换到淘宝源
执行以下命令切换到淘宝源:
nrm use taobao
切换成功后,再执行安装 vue-router
或者其他依赖资源的命令:
npm install vue-router
安装成功: