npm 安装 与 切换 淘宝镜像

一、镜像源

npm默认镜像源是国外的,安装依赖速度较慢,使用国内的镜像源速度会快一些。

1、设置淘宝镜像源:

#最新地址 淘宝 NPM 镜像站喊你切换新域名啦!

npm config set registry https://registry.npm.taobao.org(弃用了)

npm config set registry https://registry.npmmirror.com(新的)

2、查看当前镜像源:

npm config get registry

3、设置官方镜像源:

npm config set registry https://registry.npmjs.org

还可以使用nrm查看和切换镜像

//安装nrm,一定要全局安装

npm install -g nrm

//nrm查看所有镜像源命令,带*即为当前使用的源

nrm ls

npm ---------- https://registry.npmjs.org/

yarn --------- https://registry.yarnpkg.com/

tencent ------ https://mirrors.cloud.tencent.com/npm/

cnpm --------- https://r.cnpmjs.org/

* taobao ------- https://registry.npmmirror.com/

npmMirror ---- https://skimdb.npmjs.com/registry/

//如果使用nrm ls发现全面都没有带*,则可以参考最后面的教程

//切换镜像源命令

nrm use xxx //例:nrm use taobao 就可以切换自己想用的镜像源了

//当前使用的源

nrm current

taobao

二、使用cnpm安装

npm install -g cnpm --registry=https://registry.npmmirror.com

注册模块镜像

npm set registry https://registry.npmmirror.com

// node-gyp 编译依赖的 node 源码镜像

npm set disturl https://npmmirror.com/dist

// 清空缓存

npm cache clean --force

// 安装cnpm

npm install -g cnpm --registry=https://registry.npmmirror.com

三、常见包地址

mirror config

sharp_binary_host = https://npmmirror.com/mirrors/sharp

sharp_libvips_binary_host = https://npmmirror.com/mirrors/sharp-libvips

profiler_binary_host_mirror = https://npmmirror.com/mirrors/node-inspector/

fse_binary_host_mirror = https://npmmirror.com/mirrors/fsevents

node_sqlite3_binary_host_mirror = https://npmmirror.com/mirrors

sqlite3_binary_host_mirror = https://npmmirror.com/mirrors

sqlite3_binary_site = https://npmmirror.com/mirrors/sqlite3

sass_binary_site = https://npmmirror.com/mirrors/node-sass

electron_mirror = https://npmmirror.com/mirrors/electron/

puppeteer_download_host = https://npmmirror.com/mirrors

chromedriver_cdnurl = https://npmmirror.com/mirrors/chromedriver

operadriver_cdnurl = https://npmmirror.com/mirrors/operadriver

phantomjs_cdnurl = https://npmmirror.com/mirrors/phantomjs

python_mirror = https://npmmirror.com/mirrors/python

registry = https://registry.npmmirror.com

disturl = https://npmmirror.com/dist

相关推荐
腾讯TNTWeb前端团队6 小时前
helux v5 发布了,像pinia一样优雅地管理你的react状态吧
前端·javascript·react.js
范文杰9 小时前
AI 时代如何更高效开发前端组件?21st.dev 给了一种答案
前端·ai编程
拉不动的猪9 小时前
刷刷题50(常见的js数据通信与渲染问题)
前端·javascript·面试
拉不动的猪9 小时前
JS多线程Webworks中的几种实战场景演示
前端·javascript·面试
FreeCultureBoy10 小时前
macOS 命令行 原生挂载 webdav 方法
前端
uhakadotcom11 小时前
Astro 框架:快速构建内容驱动型网站的利器
前端·javascript·面试
uhakadotcom11 小时前
了解Nest.js和Next.js:如何选择合适的框架
前端·javascript·面试
uhakadotcom11 小时前
React与Next.js:基础知识及应用场景
前端·面试·github
uhakadotcom11 小时前
Remix 框架:性能与易用性的完美结合
前端·javascript·面试
uhakadotcom11 小时前
Node.js 包管理器:npm vs pnpm
前端·javascript·面试