vuejs/vue-cli · error · Error
Invalid type for option 'vuePlugins.service', expected 'arra
Error message
Invalid type for option 'vuePlugins.service', expected 'array' but got ${typeof files}. What it means
Service.loadUserOptions reads local plugins from the `vuePlugins.service` field in package.json and maps each entry to a module file. It must be an array of path strings; any other type cannot be iterated with `.map`, so it is rejected with the actual typeof received.
Source
Thrown at packages/@vue/cli-service/lib/Service.js:222
if (!apply) {
warn(`Optional dependency ${id} is not installed.`)
apply = () => {}
}
return { id, apply }
} else {
return idToPlugin(id, resolveModule(id, this.pkgContext))
}
})
plugins = builtInPlugins.concat(projectPlugins)
}
// Local plugins
if (this.pkg.vuePlugins && this.pkg.vuePlugins.service) {
const files = this.pkg.vuePlugins.service
if (!Array.isArray(files)) {
throw new Error(`Invalid type for option 'vuePlugins.service', expected 'array' but got ${typeof files}.`)
}
plugins = plugins.concat(files.map(file => ({
id: `local:${file}`,
apply: loadModule(`./${file}`, this.pkgContext)
})))
}
debug('vue:plugins')(plugins)
const orderedPlugins = sortPlugins(plugins)
debug('vue:plugins-ordered')(orderedPlugins)
return orderedPlugins
}
async run (name, args = {}, rawArgv = []) {
// resolve mode
// prioritize inline --mode
// fallback to resolved default modes from plugins or development if --watch is definedView on GitHub (pinned to 7eb93c169c)
Solutions
- Wrap the value in an array: `"service": ["./vue-cli-plugin-custom.js"]`.
- Each array entry must be a path string resolvable from the project root.
Example fix
// package.json "vue" field — before
"vue": { "vuePlugins": { "service": "./my-plugin.js" } }
// after
"vue": { "vuePlugins": { "service": ["./my-plugin.js"] } } Defensive patterns
Strategy: type-guard
Validate before calling
const service = (require('./package.json').vue || {}).vuePlugins && require('./package.json').vue.vuePlugins.service
if (service != null && !Array.isArray(service)) {
throw new Error(`vuePlugins.service must be an array, got ${typeof service}`)
} Type guard
const isServicePlugins = (v) => v == null || Array.isArray(v)
Prevention
- Always wrap vuePlugins.service entries in an array in package.json.
- Prefer vue.config.js for richer plugin config over the package.json vue field.
When it happens
Trigger: Setting `"vuePlugins": { "service": "foo.js" }` (a string) or an object/number in package.json's `vue` field instead of an array.
Common situations: Misunderstanding the field shape; copy-paste from docs that showed a single value; hand-editing package.json.
Related errors
- Error loading Vue CLI config in package.json: the "vue" fiel
- transpileDependencies only accepts an array of string or reg
- Error loading ${fileConfigPath}: should export an object or
- Cannot find polyfill ${item}, please refer to 'core-js-compa
- ${workboxPluginMode} is not a supported Workbox webpack plug
AI-assisted analysis of vuejs/vue-cli@7eb93c169c (2026-08-13).
Data as JSON: /api/errors/777ddc9415b1a2c9.
Report an issue: GitHub.