yarn

Anh-Thi Dinh
draft
yarn creates yarn.lock (whereas npm creates package-lock.json). They both use package.json with the same structure (but with different algorithms).

Install

1# Install yarn
2npm install --global yarn
3yarn --version
1# Install all packages in package.json
2yarn install # or just "yarn"
3
4# Forcing a re-download of all packages
5yarn install --force
6
7# Install only prod dependencies
8yarn install --production
9
10# Add a single package
11yarn add <package>
12yarn add -D <package> # in devDependencies

Remove

1# Remove a package
2yarn remove <package>

Check

1# Check version of a package
2yarn list # all
3yarn list --depth=0
4# (maybe)
5yarn check <package>
1# npx like?
2# No, just use npx!

Update / Upgrade

1# Update/Upgrade all package (with interactive interface)
2# Require: yarn.lock & package-lock.json removed & run "yarn" once
3yarn upgrade-interactive --latest
4
5# Upgrade a single package (not update package.json when using caret range, i.e. "^")
6yarn upgrade package_name --latest
7
8# Show list of versions + update package.json
9yarn upgrade notion-client@^ # notion-client is the package
10
11# If you wanna automatically update package.json
12# Don't use range in the version of the package, ie. just "notion-client": "6.16.0" instead of
13# "^6.16.0" or "~6.16.0" and then run
14yarn upgrade notion-client --latest

Versions

1yarn version --patch # 1.0.0 -> 1.0.1 (fixes)
2yarn version --minor # 1.0.1 -> 1.1.0 (new features )
3yarn version --major # 1.1.0 -> 2.0.0 (completely new APIs)
Loading comments...