yarn is a substitute npm package management tool facebook release.
yarn features:
- Super-fast.
- Yarn caches every downloaded package, so no need to repeat the download when used again. While taking advantage of parallel downloads to maximize resource utilization, therefore installation faster.
- Super-safe.
Before executing code, Yarn will each installation package integrity check by the algorithm. - Super reliable.
Use detailed, concise and clear format file lock installation algorithm, Yarn can guarantee no difference in the different systems work. -
yarn installation:
macos under installation
brew install yarn
Download node.js, using npm install
npm install -g yarn
yarn --version
Yarn Taobao source mounted respectively to copy and paste the following lines of code to run the black window
yarn config set registry https://registry.npm.taobao.org -g
yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g
yarn commonly used commands:
Installation yarn
npm install -g yarn
After installation, you can check the version number:
yarn --version
Global installation package
yarn golbal add <package>
Create a project file
Create a folder yarn
md yarn
into the yarn folder
cd yarn
initialize the project
yarn init
// with npm init, after the input that will generate package.json file
yarn configuration items:
yarn config list
// display all configuration items
yarn config get <key>
// display a configuration item
yarn config delete <key>
// delete a configuration item
yarn config set <key> <value> [-g|--global]
// set the configuration item
yarn global list
// Get the list of installation packages yarn
Installation package:
yarn install
// install package.json in all packages , and package and all its dependencies save into yarn.lock
yarn install --flat
// install a single version of a package
yarn install --force
// forced to re-download all the packages
yarn install --production
// only install dependencies in the package
yarn install --no-lockfile
// not read or generated yarn.lock
yarn install --pure-lockfile
// not generated yarn.lock
Add Package (updated package.json and yarn.lock):
yarn add [package]
// add a current project dependencies automatically updated to package.json and yarn.lock file
yarn add [package]@[version]
// install the specified version, here refers to the major version, if you need accurate to the small version, use the -E parameter
yarn add [package]@[tag]
/ / install a tag (such as beta, next or latest)
// do not specify depend on the type of installation to the default dependencies, you can also specify dependency types:
yarn add --dev/-D
// added devDependencies
yarn add --peer/-P
// added peerDependencies
yarn add --optional/-O
// added optionalDependencies
// default latest major version in the installation package, the following two commands can be specified version:
yarn add --exact/-E
// accurate version of the installation package. For example yarn add [email protected] will accept version 1.9.1, but the yarn add [email protected] --exact only accept version 1.2.3
yarn add --tilde/-T
the latest version of the minor release // installation package inside. For example yarn add [email protected] --tilde will accept 1.2.9, but does not accept 1.3.0
Release package
yarn publish
to remove a package
yarn remove <packageName>
: remove a package, it will automatically update package.json and yarn.lock
Update a dependency
yarn upgrade
for the update package to the latest version based on the specification range
Run the script
yarn run
to execute scripts in the scripts defined attributes package.json
Display information about a package
yarn info <packageName>
can be used to view the latest version of a module information
Cache
yarn cache
yarn cache list
# cached list of each package
yarn cache dir
# Returns the global cache location
yarn cache clean
# Clear Cache
yarn and compare npm