使用nrm
步骤1:安装nrm
nrm是一个Node.js的源管理工具,可以用于快速切换Node.js的源。
在命令行中执行以下命令安装nrm:
npm install -g nrm
步骤2:切换源
在命令行中执行以下命令切换到淘宝源:
nrm use taobao
切换成功提示:
SUCCESS The registry has been changed to 'taobao'.
***其他命令
nrm -h
Usage: nrm [options] [command]
Options:
-V, --version output the version number
-h, --help display help for command
Commands:
ls List all the registries
current [options] Show current registry name or URL
use <name> Change current registry
add <name> <url> [home] Add custom registry
login [options] <name> [base64] Set authorize information for a custom registry with a base64 encoded string or username and password
set-hosted-repo <name> <repo> Set hosted npm repository for a custom registry to publish package
set-scope <scopeName> <url> Associating a scope with a registry
del-scope <scopeName> Remove a scope
set [options] <name> Set a custom registry attribute
rename <name> <newName> Change custom registry name
del <name> Delete custom registry
home <name> [browser] Open the homepage of registry with optional browser
test [registry] Show response time for specific or all registries
help [command] display help for command