title: Yarn和Npm的相爱相杀
tags:
  - yarn
  - npm
categories:
  - 工具
top_img: false
cover: '/upload/cdn0files/20200801194600.jpeg'
abbrlink: d81893d4
date: 2020-08-01 19:44:01
updated: 2023-12-30 20:44:01
copyright:

安装

  1. 通过 msi 安装,下载链接:yarn

  2. 通过 Chocolatey 安装

    choco install yarn
    
  3. 通过 Scoop 安装

    scoop install yarn
    

前提是你要安装了 node.js

优点

yarn 有以下3个优点 :

  • 安装速度快 (服务器速度快 , 并且是并行下载)
  • 版本锁定
  • 缓存机制

Yarn 语法

npm init
npm install
npm install xxx@1.1.1 -g
npm install xxx@1.1.1 --save
npm install xxx@1.1.1 --save-dev
npm uninstall xxx --save(-dev)
npm run xxx

相对应的 yarn 语句为:

yarn init
yarn
yarn global add xxx@1.1.1
yarn add xxx@1.1.1
yarn add xxx@1.1.1 --dev
yarn remove xxx
yarn run xxxx

先说在这,最近比较忙,有时间再更新细节,88~