{"record":{"id":"76be357a11d7bd4e","repo":"vuejs/vue-cli","slug":"error-loading-fileconfigpath-should-export-an","errorCode":null,"errorMessage":"Error loading ${fileConfigPath}: should export an object or a function that returns object.","messagePattern":"Error loading (.+?): should export an object or a function that returns object\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/@vue/cli-service/lib/util/resolveUserConfig.js","lineNumber":30,"sourceCode":"function removeSlash (config, key) {\n  if (typeof config[key] === 'string') {\n    config[key] = config[key].replace(/\\/$/g, '')\n  }\n}\n\nmodule.exports = function resolveUserConfig ({\n  inlineOptions,\n  pkgConfig,\n  fileConfig,\n  fileConfigPath\n}) {\n  if (fileConfig) {\n    if (typeof fileConfig === 'function') {\n      fileConfig = fileConfig()\n    }\n\n    if (!fileConfig || typeof fileConfig !== 'object') {\n      throw new Error(\n        `Error loading ${chalk.bold(fileConfigPath)}: ` +\n        `should export an object or a function that returns object.`\n      )\n    }\n  }\n\n  // package.vue\n  if (pkgConfig && typeof pkgConfig !== 'object') {\n    throw new Error(\n      `Error loading Vue CLI config in ${chalk.bold(`package.json`)}: ` +\n      `the \"vue\" field should be an object.`\n    )\n  }\n\n  let resolved, resolvedFrom\n  if (fileConfig) {\n    const configFileName = path.basename(fileConfigPath)\n    if (pkgConfig) {","sourceCodeStart":12,"sourceCodeEnd":48,"githubUrl":"https://github.com/vuejs/vue-cli/blob/7eb93c169c7520935252e2473387f923ef80d856/packages/@vue/cli-service/lib/util/resolveUserConfig.js#L12-L48","documentation":"resolveUserConfig loads vue.config.js. Its export must be a plain object, or a function that returns one (functions are called and the result re-checked). After that, the value must be a non-null object; a string, number, array, boolean, or a function returning null/undefined is rejected.","triggerScenarios":"vue.config.js exporting a primitive (`module.exports = '...'`), an array, or a function that returns null/undefined/a non-object.","commonSituations":"Missing/wrong default export; a function config with a code path that returns undefined; accidentally exporting a config builder without calling it.","solutions":["Export an object: `module.exports = { ... }`.","If using a function, ensure every path returns a non-null object: `module.exports = () => ({ ... })`."],"exampleFix":"// vue.config.js — before\nmodule.exports = () => { configureWebpack: {} }\n// after\nmodule.exports = () => ({ configureWebpack: {} })","handlingStrategy":"type-guard","validationCode":"const cfg = require('./vue.config.js')\nconst resolved = typeof cfg === 'function' ? cfg() : cfg\nif (!resolved || typeof resolved !== 'object' || Array.isArray(resolved)) {\n  throw new Error('vue.config.js must export an object or a function returning an object')\n}","typeGuard":"const isVueConfig = (c) => typeof c === 'function' || (typeof c === 'object' && c !== null && !Array.isArray(c))","tryCatchPattern":null,"preventionTips":["Default-export an object literal in vue.config.js.","If using a function, ensure every return path yields a non-null object."],"tags":["configuration","vue-config","type-validation"],"backgroundTag":null,"analyzedSha":"7eb93c169c7520935252e2473387f923ef80d856","analyzedAt":"2026-08-13T10:13:37.803Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}