Usage of yarn

Install 

npm install -g yarn

Use npm to install globally or you can also use the installation method on the official website 

Installation original address: yarn official website


start a new project

yarn init

add a dependency

yarn add [package]
yarn add [package]@[version]
yarn add [package]@[tag]

Add dependencies to different categories of dependencies

Add to devDependencies, peerDependenciesand optionalDependenciesrespectively:

yarn add [package] --dev
yarn add [package] --peer
yarn add [package] --optional

upgrade dependencies

yarn upgrade [package]
yarn upgrade [package]@[version]
yarn upgrade [package]@[tag]

remove dependencies

yarn remove [package]

Install all dependencies of the project

yarn

or

yarn install

Comparison of npm and yarn commands

above sea level yarn
npm install yarn install
(N/A) yarn install --flat
(N/A) yarn install --har
(N/A) yarn install --no-lockfile
(N/A) yarn install --pure-lockfile
npm install [package] (N/A)
npm install --save [package] yarn add [package]
npm install --save-dev [package] yarn add [package] [--dev/-D]
(N/A) yarn add [package] [--peer/-P]
npm install --save-optional [package] yarn add [package] [--optional/-O]
npm install --save-exact [package] yarn add [package] [--exact/-E]
(N/A) yarn add [package] [--tilde/-T]
npm install --global [package] yarn global add [package]
npm rebuild yarn install --force
npm uninstall [package] (N/A)
npm uninstall --save [package] yarn remove [package]
npm uninstall --save-dev [package] yarn remove [package]
npm uninstall --save-optional [package] yarn remove [package]
npm cache clean yarn cache clean
rm -rf node_modules && npm install yarn upgrade


Yarn usage original address: yarn official website

yarn vs npm command comparison: yarn vs npm command comparison

I hope my experience of entering the pit is helpful to you, may the Holy Light be with you



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324350302&siteId=291194637