Desktop Material

Working with Packages

As we are using yarn for managing packages, here are some helpful tips for whenever you need to work with them.

Install packages

To ensure you have the right version of dependencies, run this command after cloning or switching branches.

> yarn

This will restore the versions stored in the lock file to the node_modules folder.

Add new packages

Rather than updating the package.json explicitly, you can install new dependencies via the yarn command line:

# adds the package to the dependencies list
> yarn add [package-name]
# adds the package to the devDependencies list
> yarn add [package-name] --dev

Updating packages

To see which packages have newer versions available:

> yarn outdated

To upgrade a package to its latest version:

> yarn upgrade --latest [package-name]

To upgrade a package to a specific version (or version range):

> yarn upgrade [package-name]@[version]

Removing packages

To remove any packages that are no longer needed:

> yarn remove [package-name]

Upgrading Yarn

Desktop uses a local version of yarn to ensure one version is used on all platforms that we develop on. To upgrade Desktop to the latest version of yarn:

# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

yarn-path "./vendor/yarn-x.y.z.js"
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

yarn-path "../vendor/yarn-x.y.z.js"