w3resource

Yarn list, lockfile, login and logout CLI commands


In this tutorial we will be guiding you on how you can use yarn's list, lockfile, login and logout CLI commands.

yarn list

The yarn list CLI command has the same behavior as Unix listing. When you run yarn list command, it will list all the dependencies for the current working directory by referencing all the package manager meta data files.

Here is an example of running yarn list is a working tree:

yarn list v1.21.1
+- [email protected]
?  +- [email protected]
+- [email protected]
?  +- [email protected]
+- [email protected]
?  +- debug@=3.1.0
+- [email protected]
Done in 0.19s

yarn list [--depth] [--pattern]

Whenever you run the yarn list command, it will display all the dependencies. If you want to restrict the depth of the dependencies, you can add a flag, --depth with the desired level to the list command.

yarn list --depth=0

Running this command on the same working tree as above will yield the following:

yarn list v1.21.1
+- [email protected]
+- [email protected]
+- [email protected]
+- [email protected]
Done in 0.17s

you should note however, that the levels are zero-indexed.

Running the yarn list --pattern <pattern> will filter the list of dependencies using the pattern flag.

Here is an example for you:

yarn list --pattern gulp```
```yarn list --pattern "gulp|grunt"```
```yarn list --pattern "gulp|grunt" --depth=1

yarn lockfile

The yarn lockfile is a rarely used command, this is because whenever you run the yarn install command it will produce a lockfile.

As of yarn 1.2.1 running this command will give an error like this:

error The lockfile command is not necessary. 'yarn install' produces a lockfile.

yarn login

The yarn login command helps you to store registry username and email.

Password is not required; it will only be required when you run a command such as yarn publish that requires authentication.

An example is shown below:

Command: yarn login

Output:

yarn login v1.21.1
question npm username: aryanvxxxx
question npm email: [email protected]
Done in 21.87s.

yarn logout

While the yarn login command helps you store a username and email, the yarn logout will help you to clear the registry?s username and email.

Previous: Yarn licenses and yarn link CLI commands
Next: Yarn outdated and yarn owner CLI commands



Follow us on Facebook and Twitter for latest update.