{"id":26092,"library":"postcss","title":"PostCSS","description":"PostCSS is a CSS post-processor and syntax transformer that uses JavaScript plugins to parse and transform stylesheets. Stable version 8.x, actively maintained with monthly minor/patch releases. Key differentiators: plugin-driven architecture (over 200 plugins), supports future CSS syntax via plugins like postcss-preset-env, used by popular tools like Autoprefixer and Stylelint. Ships TypeScript definitions, supports ESM and CJS, requires Node.js 10+ (12+ for full features). Provides a fast CSS parser with source map support and a rich plugin API.","status":"active","version":"8.5.13","language":"javascript","source_language":"en","source_url":"https://github.com/postcss/postcss","tags":["javascript","css","manipulation","parser","postcss","preprocessor","rework","source map","transform","typescript"],"install":[{"cmd":"npm install postcss","lang":"bash","label":"npm"},{"cmd":"yarn add postcss","lang":"bash","label":"yarn"},{"cmd":"pnpm add postcss","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Used by many PostCSS plugins for parsing CSS values","package":"postcss-value-parser","optional":true},{"reason":"Used by many PostCSS plugins for parsing selectors","package":"postcss-selector-parser","optional":true}],"imports":[{"note":"Default import works for ESM and CJS. Since v8, Node.js can use require('postcss') but TypeScript may need esModuleInterop.","wrong":"const postcss = require('postcss')","symbol":"postcss","correct":"import postcss from 'postcss'"},{"note":"Root is not directly exported from the main package; import from specific lib path or use postcss.parse().","wrong":"import { Root } from 'postcss'","symbol":"Root","correct":"import { Root } from 'postcss/lib/root'"},{"note":"Plugin is the type for creating PostCSS plugins. PluginCreator is internal; use Plugin.","wrong":"import { PluginCreator } from 'postcss'","symbol":"Plugin","correct":"import { Plugin } from 'postcss'"},{"note":"Container is a base class for Root and AtRule; Node is not exported directly.","wrong":"import { Node } from 'postcss'","symbol":"Container","correct":"import { Container } from 'postcss'"}],"quickstart":{"code":"import postcss from 'postcss';\n\nconst css = `\n  .foo {\n    color: red;\n  }\n`;\n\nconst result = await postcss([\n  require('autoprefixer')({ overrideBrowserslist: ['last 2 versions'] })\n]).process(css, { from: 'test.css' });\n\nconsole.log(result.css);\n// Output includes vendor prefixes if needed","lang":"typescript","description":"Shows basic PostCSS usage with Autoprefixer plugin: parse CSS, apply plugins, get output string."},"warnings":[{"fix":"Upgrade to Node.js 16+.","message":"Node.js 14 or earlier is no longer supported for PostCSS 8.5.x","severity":"breaking","affected_versions":">=8.5.0"},{"fix":"Always pass an array of plugins: postcss([...]).process(css).","message":"postcss().process() without a plugin array may behave unexpectedly","severity":"deprecated","affected_versions":">=8.0.0"},{"fix":"Use import postcss from 'postcss' with esModuleInterop enabled in tsconfig.json.","message":"Using require('postcss') in CJS mode may cause TypeScript type inference issues","severity":"gotcha","affected_versions":">=8.0.0"},{"fix":"Wrap in try/catch or use .catch() on the promise returned by .process().","message":"PostCSS errors from plugins are not caught by default; unhandled promise rejections","severity":"gotcha","affected_versions":">=8.0.0"},{"fix":"Use postcss-scss or postcss-syntax packages for non-standard syntax.","message":"The `sugarss` and `safe` parser options removed in v8","severity":"breaking","affected_versions":">=8.0.0"},{"fix":"Write plugins as functions directly: (root, result) => { ... }.","message":"postcss.plugin() helper function deprecated","severity":"deprecated","affected_versions":">=8.0.0"},{"fix":"Always pass both 'from' and 'to' (or at least 'from') to .process().","message":"Source maps may be misaligned if 'from' and 'to' options are not provided consistently","severity":"gotcha","affected_versions":">=8.0.0"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use await postcss([...]).process(css) or properly chain .then()","cause":"Result from postcss().process() is a promise; forgot to await or use .then()","error":"TypeError: Cannot read properties of undefined (reading 'type')"},{"fix":"Upgrade autoprefixer to 10.x for PostCSS 8: npm install autoprefixer@latest","cause":"Incompatible plugin version with installed PostCSS major version","error":"Error: PostCSS plugin autoprefixer requires PostCSS 8. Update PostCSS or see: https://github.com/postcss/autoprefixer"},{"fix":"Run npm install postcss --save-dev","cause":"PostCSS not installed or incorrectly referenced in package.json","error":"Error: Failed to find 'postcss' module"},{"fix":"Import Root from 'postcss/lib/root' or use postcss.parse() which returns a Root node","cause":"Trying to import Root directly from 'postcss' instead of 'postcss/lib/root'","error":"TS2305: Module '\"postcss\"' has no exported member 'Root'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}