{"record":{"id":"4636a77a0b18af10","repo":"vuejs/vue-cli","slug":"metadata-error","errorCode":null,"errorMessage":"metadata.error","messagePattern":"metadata\\.error","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@vue/cli/lib/util/ProjectPackageManager.js","lineNumber":322,"sourceCode":"    const headers = {}\n    if (!full) {\n      headers.Accept = 'application/vnd.npm.install-v1+json;q=1.0, application/json;q=0.9, */*;q=0.8'\n    }\n\n    const authConfig = await this.getAuthConfig(scope)\n    if ('password' in authConfig) {\n      const credentials = Buffer.from(`${authConfig.username}:${authConfig.password}`).toString('base64')\n      headers.Authorization = `Basic ${credentials}`\n    }\n    if ('token' in authConfig) {\n      headers.Authorization = `Bearer ${authConfig.token}`\n    }\n\n    const url = `${registry.replace(/\\/$/g, '')}/${packageName}`\n    try {\n      metadata = (await request.get(url, { headers }))\n      if (metadata.error) {\n        throw new Error(metadata.error)\n      }\n      metadataCache.set(metadataKey, metadata)\n      return metadata\n    } catch (e) {\n      error(`Failed to get response from ${url}`)\n      throw e\n    }\n  }\n\n  async getRemoteVersion (packageName, versionRange = 'latest') {\n    const metadata = await this.getMetadata(packageName)\n    if (Object.keys(metadata['dist-tags']).includes(versionRange)) {\n      return metadata['dist-tags'][versionRange]\n    }\n    const versions = Array.isArray(metadata.versions) ? metadata.versions : Object.keys(metadata.versions)\n    return semver.maxSatisfying(versions, versionRange)\n  }\n","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/vuejs/vue-cli/blob/7eb93c169c7520935252e2473387f923ef80d856/packages/@vue/cli/lib/util/ProjectPackageManager.js#L304-L340","documentation":"Thrown by ProjectPackageManager.getMetadata when the npm registry responds with a successful HTTP status but the response body contains an `error` field. This typically happens when the registry returns a structured error message (e.g., package not found, rate limited, or authentication required) rather than expected package metadata. The raw error string from the JSON body is re-thrown.","triggerScenarios":"Querying a private registry that returns JSON with an error field for a non-existent or unauthorized package. Hitting a registry rate limit that returns a JSON error body. Using a custom registry URL that proxies and returns error objects instead of 4xx/5xx status codes.","commonSituations":"Corporate npm proxy/artifactory that returns structured JSON errors. Misconfigured registry URL in .npmrc. Authentication token expired for a private registry. Package name typo sent to a registry that returns JSON error bodies instead of 404.","solutions":["Verify the package name is correct and exists on the configured registry.","Check registry configuration: `npm config get registry` and ensure it points to the right endpoint.","Verify authentication: ensure .npmrc has valid credentials or token for private registries.","Try the registry URL directly in a browser or with curl to inspect the error response body."],"exampleFix":"# before\nregistry: https://npm.corp.example.com/\npackage not found -> JSON {\"error\":\"not_found\"}\n# after\n$ npm config get registry  # verify URL\n$ curl -s https://registry.npmjs.org/vue  # test public\n# fix registry or auth in .npmrc\nregistry=https://registry.npmjs.org/","handlingStrategy":"try-catch","validationCode":"const request = require('request');\nconst registry = require('npm-conf')().registry;\n// Pre-check: verify registry is reachable and package exists\nrequest.get(`${registry}/${packageName}`, (err, res, body) => {\n  if (err) console.error('Registry unreachable:', err.message);\n  else if (JSON.parse(body).error) console.error('Registry error:', JSON.parse(body).error);\n});","typeGuard":null,"tryCatchPattern":"try {\n  const metadata = await pm.getMetadata(packageName);\n} catch (e) {\n  if (e.message && typeof e.message === 'string' && !e.message.includes('Failed to get response')) {\n    console.error(`Registry returned an error for ${packageName}: ${e.message}`);\n    console.error('Check: registry URL, package name, and authentication credentials.');\n  }\n  throw e;\n}","preventionTips":["Verify the registry URL with `npm config get registry`.","Ensure authentication tokens/credentials in .npmrc are valid and not expired.","Test registry connectivity with `npm ping` or a direct curl to the package endpoint.","Confirm package name spelling to avoid 'not_found' errors from private registries."],"tags":["network","registry","npm","metadata","authentication","package-manager"],"backgroundTag":null,"analyzedSha":"7eb93c169c7520935252e2473387f923ef80d856","analyzedAt":"2026-08-13T10:13:37.803Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}