How To Fix "No Such File Or Directory: 'Install'" Error When Running Yarn Install?

Published July 30, 2024

Problem: "No Such File Or Directory: 'Install'" Error During Yarn Install

The "No Such File Or Directory: 'Install'" error can happen when you run the yarn install command. This error usually means Yarn can't find the files or directories it needs to complete the installation.

Solving the Yarn Install Error

Method 1: Removing conflicting packages

To fix the "No Such File Or Directory: 'Install'" error, remove conflicting packages:

  1. Uninstall cmdtest:

    sudo apt remove cmdtest
  2. Remove the existing Yarn installation:

    sudo apt remove yarn

Tip: Check for Lingering Yarn Files

After removing Yarn, check for any remaining files:

sudo find / -name "yarn*"

If any files are found, remove them manually to avoid conflicts during reinstallation.

Method 2: Reinstalling Yarn correctly

After removing conflicting packages, reinstall Yarn from the official source:

  1. Add the Yarn repository:

    curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
    echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
  2. Update package lists:

    sudo apt-get update
  3. Install Yarn from the official source:

    sudo apt-get install yarn -y

Verifying the Fix

Running Yarn install again

After removing conflicting packages and reinstalling Yarn, you can check if the fix worked by running the Yarn install command again:

yarn install

If the installation succeeds, you'll see output like this:

yarn install v1.22.19
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...

success Saved lockfile.
Done in 5.67s.

The version numbers and timing may differ, but you should see progress through the four stages of package resolution, fetching, linking, and building. No error messages and a "success" message at the end show that Yarn is installed correctly and working as expected.

If you see warnings about Node.js version compatibility, consider updating your Node.js to a supported version for better performance.

Tip: Verify Package Installation

After running 'yarn install', you can double-check that specific packages were installed correctly by running:

yarn list [package-name]

This command will show the installed version of the package and its dependencies.