Config File Locator

Yarn config file locations


Commands use a POSIX shell (macOS, Linux, or WSL). Install the named editor or CLI first. Before using an environment-variable path, check that the variable is set to a non-empty, intended path. When using vi or Notepad, ensure the parent directory exists and is writable. A missing file is created when you save it; Notepad may ask to create it.

This page covers Yarn Modern (2+). Yarn reads .yarnrc.yml in the current directory and its ancestors, with nearer files overriding the same settings farther up the tree; the home configuration supplies user defaults. Environment variables can override file settings. Yarn Classic (1.x) uses .yarnrc and is not covered here. YARN_RC_FILENAME can change the filename searched for.

  1. Project level

    Project overrides

    Usually kept at the project root. Run commands from the project root.

    Config file location
    <project>/.yarnrc.yml
    Use YAML syntax and the .yml extension. Modern Yarn does not use .npmrc for its settings.
    Commands
    vi "./.yarnrc.yml"
  2. Parent directories

    Inherited settings

    Yarn also reads configuration files in ancestor directories. Closer files take precedence for the same setting.

    Config file location
    <parent>/.yarnrc.yml
    Replace <parent> with an actual ancestor directory. More than one ancestor can provide settings.

    Replace <parent> with the ancestor directory whose Yarn settings you intend to edit before running. Keep the surrounding quotes for paths containing spaces.

    Command templates
    vi "<parent>/.yarnrc.yml"
  3. User level

    User defaults

    User defaults stored in the home directory.

    Config file location
    ~/.yarnrc.yml
    The file may not exist until you create home configuration.
    Commands
    vi "$HOME/.yarnrc.yml"

Inspect configuration
yarn config

Official Yarn documentation