As we are using yarn
for managing packages, here are some helpful tips for
whenever you need to work with them.
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.
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
To see which packages have newer versions available:
> yarn outdated
To upgrade a package:
> yarn upgrade [package-name]@[version]
You don't need to specify the version here, but this ensures the change is
reflected in the package.json
file.
To remove any packages that are no longer needed:
> yarn remove [package-name]