{"record":{"id":"d2ec18969dc1ab6c","repo":"parcel-bundler/parcel","slug":"postcss-config-should-be-an-object","errorCode":null,"errorMessage":"PostCSS config should be an object.","messagePattern":"PostCSS config should be an object\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/transformers/postcss/src/loadConfig.js","lineNumber":196,"sourceCode":"      specifier: 'postcss',\n      resolveFrom: config.searchPath,\n      range: POSTCSS_RANGE,\n    });\n\n    contents = configFile.contents;\n    let isDynamic =\n      configFile && path.extname(configFile.filePath).endsWith('js');\n    if (isDynamic) {\n      // We have to invalidate on startup in case the config is non-deterministic,\n      // e.g. using unknown environment variables, reading from the filesystem, etc.\n      logger.warn({\n        message:\n          'WARNING: Using a JavaScript PostCSS config file means losing out on caching features of Parcel. Use a .postcssrc(.json) file whenever possible.',\n      });\n    }\n\n    if (typeof contents !== 'object') {\n      throw new Error('PostCSS config should be an object.');\n    }\n\n    if (\n      contents.plugins == null ||\n      typeof contents.plugins !== 'object' ||\n      Object.keys(contents.plugins).length === 0\n    ) {\n      throw new Error('PostCSS config must have plugins');\n    }\n  }\n\n  return configHydrator(\n    contents,\n    config,\n    configFile?.filePath,\n    options,\n    logger,\n  );","sourceCodeStart":178,"sourceCodeEnd":214,"githubUrl":"https://github.com/parcel-bundler/parcel/blob/59484858a1a0bcbb71f74088956bb437a2db6505/packages/transformers/postcss/src/loadConfig.js#L178-L214","documentation":"Thrown by @parcel/transformer-postcss's config loader when the parsed PostCSS config file is not a plain object (typeof contents !== 'object'). This typically means a JS config that exports a non-object (string, number, array, null after JSON parse, or a function/class in JS configs that Parcel evaluates to a non-object).","triggerScenarios":"A PostCSS config (`.postcssrc`, `.postcssrc.json`, `.postcssrc.js`, `postcss.config.js`, or the `postcss` key in package.json) whose evaluated value fails the `typeof === 'object'` check. Examples: postcss.config.js with `module.exports = 'tailwind'`, a JSON file containing an array, or a JS file that conditionally returns null.","commonSituations":"Hand-editing postcss.config.js and forgetting the object literal; copy-pasting a config snippet that exports a string; using CommonJS in an ESM project so `module.exports` evaluates to undefined and gets coerced; malformed `.postcssrc.json` that is a JSON array.","solutions":["Open the named PostCSS config file and ensure it exports an object literal `{ ... }`.","For JS configs, double check `module.exports = { ... }` (CommonJS) or the equivalent default export.","For JSON configs, make sure the top-level value is `{ }`, not an array or scalar.","If the config is dynamic/conditional, ensure every code path returns an object."],"exampleFix":"// before: postcss.config.js\nmodule.exports = 'tailwindcss';\n// after\nmodule.exports = {\n  plugins: {\n    tailwindcss: {}\n  }\n};","handlingStrategy":"type-guard","validationCode":"function assertPostCSSConfigShape(contents) {\n  if (typeof contents !== 'object' || contents === null || Array.isArray(contents)) {\n    throw new Error('PostCSS config must be a plain object');\n  }\n}","typeGuard":"function isPostCSSConfigObject(contents) {\n  return contents !== null && typeof contents === 'object' && !Array.isArray(contents);\n}","tryCatchPattern":null,"preventionTips":["Prefer .postcssrc.json over JS configs — they cannot accidentally export a non-object.","Lint JS PostCSS configs in CI by requiring and checking typeof === 'object'."],"tags":["postcss","config","css","transformer"],"backgroundTag":null,"analyzedSha":"59484858a1a0bcbb71f74088956bb437a2db6505","analyzedAt":"2026-08-13T04:06:35.925Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}