Yarn、NPM包管理工具源设置

Yarn、NPM包管理工具源设置(解决yarn、npm下载安装慢的问题)

YarnNPM (npx) 是主流的资源包管理工具,默认安装使用时,下载资源的速度非常慢。其主要原因是 npm 资源包默认的服务器在国外,当使用 yarn 和 npm 安装资源包时候,速度非常慢。为了解决下载速度的问题,大多使用阿里的 淘宝镜像cnpm)来解决下载速度慢安装失等问题。

安装淘宝镜像

npm install -g cnpm --registry=https://registry.npm.taobao.org
  • 安装模块
cnpm install [name]
  • 移除模块
cnpm uninstall [name]

查看源/切换源

  • 查看源
yarn config get registry
// yarn 当前(默认)镜像源:https://registry.yarnpkg.com/

npm config get registry
// npm 当前(默认)镜像源:https://registry.npmjs.org/
  • 设置源
yarn config set registry https://registry.npm.taobao.org
// yarn、npm 切换淘宝镜像源
npm config set registry https://registry.npm.taobao.org
  • Yarn下载

查看npm安装的插件

// npm 查看全局安装的包
npm list -g --depth -0

// yarn 查看全局安装的包
yarn global list

猜你喜欢

转载自blog.csdn.net/SK_21/article/details/109235564