w3resource

Yarn check and yarn config CLI commands


There are certain times when you wish to verify the versions of the package dependencies that is in your current project's package.json, yarn provides you the yarn check command to verify the packages while the yarn config helps you to manage your files.

This tutorial will explore these two CLI commands.

yarn check

The yarn check command is the command you need to run when you need to verify that the versions of the package dependencies in your project's package.json match those that are in yarn's lock file.

--integrity and --verify-tree are the optional flags available for you when running yarn check.

Both options are mutually exclusive.

yarn check --integrity

Running this command from your terminal will verify that versions and hashed values of the package contents in the project's package.json match those in yarn?s lock file. This helps to ensure that the package dependencies have not been altered.

yarn check --verify-tree

When you run this command, it will recursively verify that the dependencies in package.json are present in node_modules folder and have the right version. This check will not consideryarn.lock.

yarn config

The yarn config command helps you to manage yarn configuration files. You can set a file, read it, update it or even delete it.

yarn config set <key> <value> [-g|--global]

The config key will be set to a certain value when you run this command.

For instance, running the following command:

yarn config set

Will give the following outputs:

  • Current yarn version: ```yarn config vx.x.x```
  • A success message: ```success Set "aryanSSH" to "xxxxxxxxxxxxxxx"```.
  • Duration taken: ? ```Done in 0.05s.```

Setting a value to an already existing key will overwrite the preexisting value.

Yarn config get <key>

When you run this command it will return the most recent value for that key.

Yarn config delete <key>

The yarn config delete <key> command will delete a given key from the config. And return a success message for instance, running the following command:

Yarn config delete aryanSSH

Will yield

yarn config v1.21.1

success Deleted "aryanSSH".

Done in 0.07s.

Yarn config list

This command will display the current configuration.

yarn config v1.21.1

info yarn config

{ 'version-tag-prefix': 'v',
  'version-git-tag': true,
  'version-commit-hooks': true,
  'version-git-sign': false,
  'version-git-message': 'v%s',
  'init-version':'1.0.0',
  'init-license': 'MIT',
  'save-prefix':'^',
  'bin-links': true,
  'ignore-scripts': false,
  'ignore-optional': false,
  registry: 'https://registry.yarnpkg.com',
  'strict-ssl': true,
  'user-agent': 'yarn/1.21.1 npm/? node/v10.16.3 win32 x64',
  lastUpdateCheck:1580743470918
 }

info npm config
{ prefix: 'C:\\Users\\Awam Victor\\AppData\\Roaming\\npm',
  registry: 'https://registry.npmjs.org/',
  config: 'prefix',
  '//registry.npmjs.org/:_authToken': '5ccc5fe5-0182-48a6-a1aa-6d762cd1134f' 
}

Done in 0.10s.

Previous: Yarn bin and cache commands
Next: Yarn create, dedupe, generate-lock-entry, and global CLI commands



Follow us on Facebook and Twitter for latest update.