Yarn download installation and common configuration and command summary


title: Yarn download and installation, common configuration and command summary
date: 2023-01-13 14:47:32
tags:

  • Development tools and environment
    categories:
  • Development tools and environment
    cover: https://cover.png
    feature: false

1. Node.js

It is recommended to install Node.js first, see another article: Node.js multi-version installation and NPM mirror configuration_fan223's blog

2. Download and install

Since Node.js comes with a package manager NPM, the easier way to install Yarn is npm install --location=global yarnto

insert image description here

If you want to upgrade the Yarn version, you can first check the latest version number of Yarn from the Internet. Generally, the console will automatically prompt when there is a new version of Yarn, and then use the command to specify the version number to upgrade.npm install [email protected] --location=global

insert image description here

3. Modify the installation location of Yarn global package and cache

  1. Check the current Yarn bin location:yarn global bin
  2. Check the current Yarn global installation location:yarn global dir
  3. Check the current Yarn global cache location:yarn cache dir
  4. Modify the current global installation location of Yarn: yarn config set global-folder "自定义路径", if the global directory installed with Yarn does not take effect after modification, reopen cmd and install with Yarn
  5. Modify Yarn's cache accordingly:yarn config set cache-folder "自定义路径"
  6. Clear the global cache:yarn cache clean

4. Basic commands

NPM Yarn
npm install yarn
npm install xxx --save yarn add xxx
npm uninstall xxx --save yarn remove xxx
npm install xxx --save-dev yarn add xxx --dev
npm update --save yarn upgrade
  1. Installation package:yarn [global] add [package]@[version]
  2. Update package:yarn upgrade [package | package@tag | package@version | @scope/]... [--ignore-engines] [--pattern]
  3. Remove package:yarn remove <package...>
  4. List all packages and their dependencies:yarn list [--depth] [--pattern]
  5. Run the script:yarn run [script] [<args>]

Guess you like

Origin blog.csdn.net/ACE_U_005A/article/details/128674135