vuejs/vue-cli · error · Error

metadata.error

Error message

metadata.error

What it means

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.

Source

Thrown at packages/@vue/cli/lib/util/ProjectPackageManager.js:322

    const headers = {}
    if (!full) {
      headers.Accept = 'application/vnd.npm.install-v1+json;q=1.0, application/json;q=0.9, */*;q=0.8'
    }

    const authConfig = await this.getAuthConfig(scope)
    if ('password' in authConfig) {
      const credentials = Buffer.from(`${authConfig.username}:${authConfig.password}`).toString('base64')
      headers.Authorization = `Basic ${credentials}`
    }
    if ('token' in authConfig) {
      headers.Authorization = `Bearer ${authConfig.token}`
    }

    const url = `${registry.replace(/\/$/g, '')}/${packageName}`
    try {
      metadata = (await request.get(url, { headers }))
      if (metadata.error) {
        throw new Error(metadata.error)
      }
      metadataCache.set(metadataKey, metadata)
      return metadata
    } catch (e) {
      error(`Failed to get response from ${url}`)
      throw e
    }
  }

  async getRemoteVersion (packageName, versionRange = 'latest') {
    const metadata = await this.getMetadata(packageName)
    if (Object.keys(metadata['dist-tags']).includes(versionRange)) {
      return metadata['dist-tags'][versionRange]
    }
    const versions = Array.isArray(metadata.versions) ? metadata.versions : Object.keys(metadata.versions)
    return semver.maxSatisfying(versions, versionRange)
  }

View on GitHub (pinned to 7eb93c169c)

Solutions

  1. Verify the package name is correct and exists on the configured registry.
  2. Check registry configuration: `npm config get registry` and ensure it points to the right endpoint.
  3. Verify authentication: ensure .npmrc has valid credentials or token for private registries.
  4. Try the registry URL directly in a browser or with curl to inspect the error response body.

Example fix

# before
registry: https://npm.corp.example.com/
package not found -> JSON {"error":"not_found"}
# after
$ npm config get registry  # verify URL
$ curl -s https://registry.npmjs.org/vue  # test public
# fix registry or auth in .npmrc
registry=https://registry.npmjs.org/
Defensive patterns

Strategy: try-catch

Validate before calling

const request = require('request');
const registry = require('npm-conf')().registry;
// Pre-check: verify registry is reachable and package exists
request.get(`${registry}/${packageName}`, (err, res, body) => {
  if (err) console.error('Registry unreachable:', err.message);
  else if (JSON.parse(body).error) console.error('Registry error:', JSON.parse(body).error);
});

Try / catch

try {
  const metadata = await pm.getMetadata(packageName);
} catch (e) {
  if (e.message && typeof e.message === 'string' && !e.message.includes('Failed to get response')) {
    console.error(`Registry returned an error for ${packageName}: ${e.message}`);
    console.error('Check: registry URL, package name, and authentication credentials.');
  }
  throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


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