nodejs|npm加速安装node_module模块
如需转载请标明出处:http://blog.csdn.net/itas109
QQ技术交流群:129518033
文章目录
前言
npm默认源为https://registry.npmjs.org/,但是下载速度慢。下面介绍一下如何加速下载模块。
1.临时设置
npm i express --registry https://registry.npm.taobao.org
2.永久设置
2.1 npm config命令
设置:
npm config set registry https://registry.npm.taobao.org
查看:
npm config get registry
2.2 npmrc文件
编辑 ~/.npmrc 加入下面内容(上面的命令也是设置该文件)
registry = https://registry.npm.taobao.org
2.3 nrm命令管理源
npm i nrm -g --registry https://registry.npm.taobao.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/
测试源速度
nrm test
* npm ---- 1069ms
yarn --- 2328ms
cnpm --- 689ms
taobao - 103ms
nj ----- Fetch Error
npmMirror 935ms
edunpm - Fetch Error
切换源
nrm use taobao
nrm帮助
nrm --help
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
License
License under CC BY-NC-ND 4.0: 署名-非商业使用-禁止演绎
如需转载请标明出处:http://blog.csdn.net/itas109
QQ技术交流群:129518033
Refrence:
NULL