{"record":{"id":"7994452fa0151550","repo":"vuejs/vue-cli","slug":"the-package-json-file-at-packagepath-does-not","errorCode":null,"errorMessage":"The package.json file at '${packagePath}' does not exist","messagePattern":"The package\\.json file at '(.+?)' does not exist","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@vue/cli/lib/util/getPkg.js","lineNumber":14,"sourceCode":"// Get the package.json containing all the `vue-cli-pluin-*` dependencies\n// See issue #1815\n\nconst fs = require('fs')\nconst path = require('path')\n\nfunction getPackageJson (projectPath) {\n  const packagePath = path.join(projectPath, 'package.json')\n\n  let packageJson\n  try {\n    packageJson = fs.readFileSync(packagePath, 'utf-8')\n  } catch (err) {\n    throw new Error(`The package.json file at '${packagePath}' does not exist`)\n  }\n\n  try {\n    packageJson = JSON.parse(packageJson)\n  } catch (err) {\n    throw new Error('The package.json is malformed')\n  }\n\n  return packageJson\n}\n\nmodule.exports = function getPkg (context) {\n  const pkg = getPackageJson(context)\n  if (pkg.vuePlugins && pkg.vuePlugins.resolveFrom) {\n    return getPackageJson(path.resolve(context, pkg.vuePlugins.resolveFrom))\n  }\n  return pkg\n}","sourceCodeStart":1,"sourceCodeEnd":32,"githubUrl":"https://github.com/vuejs/vue-cli/blob/7eb93c169c7520935252e2473387f923ef80d856/packages/@vue/cli/lib/util/getPkg.js#L1-L32","documentation":"Thrown by getPackageJson in getPkg.js when fs.readFileSync fails to read the package.json file at the resolved path. The catch block converts any file-system error (ENOENT, EACCES, etc.) into this message. This function is used to load the project's package.json during CLI operations.","triggerScenarios":"Running a Vue CLI command in a directory that has no package.json, or where the project path resolves incorrectly (e.g., via vuePlugins.resolveFrom pointing to a non-existent directory). Also when file permissions prevent reading.","commonSituations":"Running `vue` commands outside a Vue project directory. Corrupted or deleted package.json. A vuePlugins.resolveFrom field in package.json pointing to a path that no longer exists. Permission issues on the file system.","solutions":["Ensure you are running the command in the project root that contains package.json.","Check that package.json exists: `ls package.json`.","If vuePlugins.resolveFrom is set, verify that the target path exists and contains a valid package.json.","Check file permissions: `ls -la package.json`."],"exampleFix":"# before\n$ cd /wrong/dir && vue serve\nError: package.json does not exist\n# after\n$ cd /path/to/vue-project\n$ ls package.json\n$ vue serve","handlingStrategy":"validation","validationCode":"const { existsSync } = require('fs');\nconst path = require('path');\nconst packagePath = path.join(projectPath, 'package.json');\nif (!existsSync(packagePath)) {\n  console.error(`No package.json found at ${packagePath}. Run this command in a project root.`);\n  process.exit(1);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const pkg = getPkg(context);\n} catch (e) {\n  if (e.message.includes('does not exist')) {\n    console.error('package.json not found. Ensure you are in the project root.');\n    process.exit(1);\n  }\n  throw e;\n}","preventionTips":["Always run Vue CLI commands from the project root containing package.json.","If using vuePlugins.resolveFrom, ensure the referenced path is valid.","Check file permissions if the file exists but is unreadable."],"tags":["filesystem","package-json","project-structure","environment"],"backgroundTag":null,"analyzedSha":"7eb93c169c7520935252e2473387f923ef80d856","analyzedAt":"2026-08-13T10:13:37.803Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}