{"record":{"id":"9de2edf632135943","repo":"vuejs/vue-cli","slug":"the-project-seems-to-require-yarn-but-it-s-not-ins","errorCode":null,"errorMessage":"The project seems to require yarn but it's not installed.","messagePattern":"The project seems to require yarn but it's not installed\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@vue/cli-shared-utils/lib/env.js","lineNumber":46,"sourceCode":"    return (_hasYarn = true)\n  } catch (e) {\n    return (_hasYarn = false)\n  }\n}\n\nexports.hasProjectYarn = (cwd) => {\n  if (_yarnProjects.has(cwd)) {\n    return checkYarn(_yarnProjects.get(cwd))\n  }\n\n  const lockFile = path.join(cwd, 'yarn.lock')\n  const result = fs.existsSync(lockFile)\n  _yarnProjects.set(cwd, result)\n  return checkYarn(result)\n}\n\nfunction checkYarn (result) {\n  if (result && !exports.hasYarn()) throw new Error(`The project seems to require yarn but it's not installed.`)\n  return result\n}\n\nexports.hasGit = () => {\n  if (process.env.VUE_CLI_TEST) {\n    return true\n  }\n  if (_hasGit != null) {\n    return _hasGit\n  }\n  try {\n    execSync('git --version', { stdio: 'ignore' })\n    return (_hasGit = true)\n  } catch (e) {\n    return (_hasGit = false)\n  }\n}\n","sourceCodeStart":28,"sourceCodeEnd":64,"githubUrl":"https://github.com/vuejs/vue-cli/blob/7eb93c169c7520935252e2473387f923ef80d856/packages/@vue/cli-shared-utils/lib/env.js#L28-L64","documentation":"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.","triggerScenarios":"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.","commonSituations":"Cloning a yarn-based project on a fresh machine/CI without yarn; switching package managers without removing the old lockfile.","solutions":["Install yarn: `npm i -g yarn` or `corepack enable`.","If you intend to use npm instead, remove the yarn.lock and reinstall.","On CI, add a yarn setup step (e.g. actions/setup-node with `cache: 'yarn'`)."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const fs = require('fs')\nconst path = require('path')\nconst { hasYarn } = require('@vue/cli-shared-utils/lib/env')\nconst needsYarn = fs.existsSync(path.join(cwd, 'yarn.lock'))\nif (needsYarn && !hasYarn()) console.warn('Project uses yarn but yarn is not installed: npm i -g yarn')","typeGuard":null,"tryCatchPattern":"try { hasProjectYarn(cwd) } catch (e) { /* prompt user to install yarn or remove yarn.lock */ }","preventionTips":["Check hasYarn() before relying on hasProjectYarn().","On CI, add a yarn install/setup step or remove yarn.lock to switch to npm."],"tags":["package-manager","yarn","environment"],"backgroundTag":null,"analyzedSha":"7eb93c169c7520935252e2473387f923ef80d856","analyzedAt":"2026-08-13T10:13:37.803Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}