vuejs/vue-cli · error · Error

Error loading Vue CLI config in package.json: the "vue" fiel

Error message

Error loading Vue CLI config in package.json: the "vue" field should be an object.

What it means

As an alternative to vue.config.js, Vue CLI reads a `"vue"` field in package.json. That field must be a configuration object; resolveUserConfig rejects any non-object (string, number, array, boolean) so config parsing stays well-defined.

Source

Thrown at packages/@vue/cli-service/lib/util/resolveUserConfig.js:39

  fileConfig,
  fileConfigPath
}) {
  if (fileConfig) {
    if (typeof fileConfig === 'function') {
      fileConfig = fileConfig()
    }

    if (!fileConfig || typeof fileConfig !== 'object') {
      throw new Error(
        `Error loading ${chalk.bold(fileConfigPath)}: ` +
        `should export an object or a function that returns object.`
      )
    }
  }

  // package.vue
  if (pkgConfig && typeof pkgConfig !== 'object') {
    throw new Error(
      `Error loading Vue CLI config in ${chalk.bold(`package.json`)}: ` +
      `the "vue" field should be an object.`
    )
  }

  let resolved, resolvedFrom
  if (fileConfig) {
    const configFileName = path.basename(fileConfigPath)
    if (pkgConfig) {
      warn(
        `"vue" field in package.json ignored ` +
        `due to presence of ${chalk.bold(configFileName)}.`
      )
      warn(
        `You should migrate it into ${chalk.bold(configFileName)} ` +
        `and remove it from package.json.`
      )
    }

View on GitHub (pinned to 7eb93c169c)

Solutions

  1. Make the `vue` field an object: `"vue": { "publicPath": "/app/" }`.
  2. Prefer vue.config.js to avoid JSON-only constraints.

Example fix

// package.json — before
"vue": ["@vue/cli-plugin-babel"]
// after
"vue": { "pluginOptions": {} }
Defensive patterns

Strategy: type-guard

Validate before calling

const vueField = require('./package.json').vue
if (vueField != null && (typeof vueField !== 'object' || Array.isArray(vueField))) {
  throw new Error('package.json "vue" field must be an object')
}

Type guard

const isVuePkgField = (v) => v == null || (typeof v === 'object' && v !== null && !Array.isArray(v))

Prevention

When it happens

Trigger: Setting `"vue": "..."` or `"vue": [...]` in package.json instead of an object.

Common situations: Putting a config string/array by mistake; copy-paste from a non-Vue-CLI example.

Related errors


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