Yarn commands cheatsheet

·2 min. read·

In this article, I will describe the basic Yarn commands and their usage, using the popular lodash package as an example.

To find out why it's better to use Yarn instead of NPM, please read this article where I compared these tools.

Install the latest version of the package:

yarn add lodash@latest

Install the latest version of the package and save to devDependencies instead of dependencies:

yarn add -D lodash@latest

Install the latest version of the package globally:

yarn add global lodash@latest

Install specific version of the package (eg 3.10.1):

Install caret version of the package (eg ^4.13.1).

When a caret version of a package is specified, it sets certain rules for updating the dependency when installing new package versions. In this case, "^4.13.1" means that Yarn can install any minor or patch version that is compatible with version 4.13.1 but should not exceed major version 5.

yarn add lodash@^4.13.1

Hint: use NPM repositories to browse the list of versions for your package. For example: lodash.

Uninstall the package:

yarn remove lodash

Uninstall the globally installed package:

yarn global remove lodash

The command `yarn set version`` allows you to switch the Yarn version at the project level.

Activate the latest stable version (4.x at the time of writing this article):

yarn set version stable

Activate the latest 3.x version:

yarn set version 3.x

Activate classic (old) 1.x version:

yarn set version classic

You may also like

How to use PM2 with Node.js

PM2 is a tool for managing Node.js processes, allowing for application... Read more
·2 min. read

Warcraft 3 Cheat Codes

Found this in old files... September 24, 2006 - kodu warcraft... Read more
·1 min. read

Developer mode in Lineage 2

To switch to developer mode, you need to edit the file system/l2.ini, or better... Read more
·3 min. read

© geekrainian.com.