vuejs/vue-cli · error · Error

The project seems to require yarn but it's not installed.

Error message

The project seems to require yarn but it's not installed.

What it means

hasProjectYarn(cwd) reports whether a project uses yarn by checking for yarn.lock; checkYarn then throws if a lockfile is present but yarn is not installed on PATH, because the project clearly depends on yarn but the environment cannot run it.

Source

Thrown at packages/@vue/cli-shared-utils/lib/env.js:46

    return (_hasYarn = true)
  } catch (e) {
    return (_hasYarn = false)
  }
}

exports.hasProjectYarn = (cwd) => {
  if (_yarnProjects.has(cwd)) {
    return checkYarn(_yarnProjects.get(cwd))
  }

  const lockFile = path.join(cwd, 'yarn.lock')
  const result = fs.existsSync(lockFile)
  _yarnProjects.set(cwd, result)
  return checkYarn(result)
}

function checkYarn (result) {
  if (result && !exports.hasYarn()) throw new Error(`The project seems to require yarn but it's not installed.`)
  return result
}

exports.hasGit = () => {
  if (process.env.VUE_CLI_TEST) {
    return true
  }
  if (_hasGit != null) {
    return _hasGit
  }
  try {
    execSync('git --version', { stdio: 'ignore' })
    return (_hasGit = true)
  } catch (e) {
    return (_hasGit = false)
  }
}

View on GitHub (pinned to 7eb93c169c)

Solutions

  1. Install yarn: `npm i -g yarn` or `corepack enable`.
  2. If you intend to use npm instead, remove the yarn.lock and reinstall.
  3. On CI, add a yarn setup step (e.g. actions/setup-node with `cache: 'yarn'`).
Defensive patterns

Strategy: validation

Validate before calling

const fs = require('fs')
const path = require('path')
const { hasYarn } = require('@vue/cli-shared-utils/lib/env')
const needsYarn = fs.existsSync(path.join(cwd, 'yarn.lock'))
if (needsYarn && !hasYarn()) console.warn('Project uses yarn but yarn is not installed: npm i -g yarn')

Try / catch

try { hasProjectYarn(cwd) } catch (e) { /* prompt user to install yarn or remove yarn.lock */ }

Prevention

When it happens

Trigger: Calling hasProjectYarn (directly or via a Vue CLI util) in a project that has a yarn.lock on a machine where yarn is not installed.

Common situations: Cloning a yarn-based project on a fresh machine/CI without yarn; switching package managers without removing the old lockfile.

Related errors


AI-assisted analysis of vuejs/vue-cli@7eb93c169c (2026-08-13). Data as JSON: /api/errors/9de2edf632135943. Report an issue: GitHub.