parcel-bundler/parcel · error · ThrowableDiagnostic
Vue config should be an object.
Error message
Vue config should be an object.
What it means
Thrown by @parcel/transformer-vue when a discovered vue.config.{js,cjs,mjs} file exports a value whose typeof is not 'object'. The transformer expects a plain configuration object (customBlocks, compilerOptions); any other shape (string, number, array, function without return) is rejected before reading keys.
Source
Thrown at packages/transformers/vue/src/VueTransformer.js:45
[
'.vuerc',
'.vuerc.json',
'.vuerc.js',
'.vuerc.cjs',
'.vuerc.mjs',
'vue.config.js',
'vue.config.cjs',
'vue.config.mjs',
],
{packageKey: 'vue'},
);
let contents = {};
if (conf) {
config.invalidateOnStartup();
contents = conf.contents;
if (typeof contents !== 'object') {
// TODO: codeframe
throw new ThrowableDiagnostic({
diagnostic: {
message: 'Vue config should be an object.',
origin: '@parcel/transformer-vue',
},
});
}
}
return {
customBlocks: contents.customBlocks || {},
filePath: conf && conf.filePath,
compilerOptions: contents.compilerOptions || {},
};
},
canReuseAST({ast}) {
return ast.type === 'vue' && semver.satisfies(ast.version, '^3.0.0');
},
async parse({asset, options}) {
// TODO: This parses the vue component multiple times. Fix?View on GitHub (pinned to 59484858a1)
Solutions
- Ensure vue.config.js exports a plain object: `module.exports = { compilerOptions: {...} }`.
- If using ESM, write `export default { compilerOptions: {} };`.
- Remove the vue.config file if no custom compiler options are needed.
- Verify the file is not accidentally exporting the result of a function call that returns a non-object.
Example fix
// before: module.exports = 'production';
// after: module.exports = { compilerOptions: { whitespace: 'condense' } }; Defensive patterns
Strategy: type-guard
Validate before calling
import conf from './vue.config';
if (conf !== null && typeof conf !== 'object' || Array.isArray(conf)) {
throw new Error('vue.config must export a plain object');
} Type guard
function isVueConfig(v) {
return v !== null && typeof v === 'object' && !Array.isArray(v);
} Prevention
- Always export a plain object literal from vue.config.js.
- Avoid `export default function()` unless you immediately invoke and return an object.
- Lint config files to reject non-object default exports.
When it happens
Trigger: Parcel resolves a vue config file via the packageKey 'vue' or one of the well-known filenames, then checks typeof conf.contents. A module-default-exported string, a named export misread, or `export default []` triggers it.
Common situations: Author writes `module.exports = 'something'` instead of an object, uses `export default function()` (function, not object), or the config file is actually a CommonJS file loaded in a way that yields module.exports = string. Also happens when a build tool rewrites the export into a non-object.
Related errors
- Unknown script language: "${script.lang}"
- Unknown style language: "${style.lang}"
- No preprocessor found for block type ${type}
- Targets option is an empty array
- Could not find target with name "${target}"
AI-assisted analysis of parcel-bundler/parcel@59484858a1 (2026-08-13).
Data as JSON: /api/errors/da2d2a8300b8ae9b.
Report an issue: GitHub.