{"id":13462,"library":"lightningcss-linux-arm64-gnu","title":"Lightning CSS (Linux ARM64 GNU)","description":"Lightning CSS is an extremely fast, Rust-based CSS parser, transformer, bundler, and minifier. This specific package, `lightningcss-linux-arm64-gnu` (current stable version `1.32.0`), provides the native aarch64-unknown-linux-gnu build of the core library. It is typically installed as a transitive dependency of the main `lightningcss` package, which dynamically loads the appropriate platform-specific binary. The library differentiates itself by offering exceptional performance (over 100x faster than some JavaScript alternatives), browser-grade parsing based on Mozilla's `cssparser` and `selectors` crates, and comprehensive support for modern CSS features, including transpilation, vendor prefixing, syntax lowering, and CSS Modules, all configurable via browser targets. Releases are frequent, with minor versions often appearing monthly or bi-monthly, reflecting active development. It can be used as a standalone library, a CLI tool, or integrated into build systems like Parcel, which includes it out of the box.","status":"active","version":"1.32.0","language":"javascript","source_language":"en","source_url":"https://github.com/parcel-bundler/lightningcss","tags":["javascript"],"install":[{"cmd":"npm install lightningcss-linux-arm64-gnu","lang":"bash","label":"npm"},{"cmd":"yarn add lightningcss-linux-arm64-gnu","lang":"bash","label":"yarn"},{"cmd":"pnpm add lightningcss-linux-arm64-gnu","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The `lightningcss` library is primarily distributed as an ES Module. While older Node.js versions might tolerate `require()`, modern usage and future compatibility strongly recommend `import`.","wrong":"const { transform } = require('lightningcss');","symbol":"transform","correct":"import { transform } from 'lightningcss';"},{"note":"`bundleAsync` is preferred for resolving `@import` rules, especially with custom resolvers. The synchronous `bundle` exists but `bundleAsync` is generally more flexible and efficient for I/O operations.","wrong":"import { bundle } from 'lightningcss';","symbol":"bundleAsync","correct":"import { bundleAsync } from 'lightningcss';"},{"note":"These are named exports for configuring browser compatibility targets and enabling/disabling specific CSS features during transformation.","wrong":"import * as lightningcss from 'lightningcss';","symbol":"browserslistToTargets, Features","correct":"import { browserslistToTargets, Features } from 'lightningcss';"}],"quickstart":{"code":"import { transform, browserslistToTargets } from 'lightningcss';\nimport browserslist from 'browserslist';\nimport fs from 'node:fs';\n\nconst cssInput = `\n  :root {\n    --primary-color: oklch(70% 0.1 270);\n  }\n  .container {\n    display: grid;\n    grid-template-areas: \"header\" \"main\" \"footer\";\n    gap: 1rem;\n    padding: env(--spacing-medium);\n  }\n  .header {\n    background-color: var(--primary-color);\n    color: white;\n    font-size: clamp(1rem, 5vw, 2.5rem);\n  }\n  @media (width <= 768px) {\n    .container {\n      grid-template-areas: \"header\" \"footer\" \"main\";\n    }\n  }\n`;\n\n// Determine browser targets from a browserslist query for optimal transpilation and prefixing\nconst targets = browserslistToTargets(browserslist('last 2 versions, > 0.5%'));\n\n// Transform and minify the CSS\ntry {\n  const { code, map } = transform({\n    filename: 'input.css',\n    code: Buffer.from(cssInput),\n    minify: true,\n    sourceMap: true,\n    targets,\n    drafts: {\n      nesting: true, // Enable CSS nesting support\n      customMedia: true // Enable custom media query support\n    },\n    // Example of a custom visitor (optional, but demonstrates advanced usage)\n    visitor: {\n      Rule: {\n        at(rule) {\n          if (rule.name === 'media' && rule.query.value.includes('width <= 768px')) {\n            // Modify or inspect media rules\n            // console.log(`Processing media query: ${rule.query.value}`);\n          }\n        }\n      }\n    }\n  });\n\n  console.log('Minified CSS:');\n  console.log(code.toString());\n  console.log('\\nSource Map (first 100 chars):');\n  console.log(map.toString().substring(0, 100) + '...');\n\n  // Example of writing to a file\n  fs.writeFileSync('output.min.css', code);\n  fs.writeFileSync('output.min.css.map', map);\n  console.log('\\nOutput written to output.min.css and output.min.css.map');\n\n} catch (error) {\n  console.error('Error transforming CSS:', error);\n}","lang":"typescript","description":"This quickstart demonstrates how to use `lightningcss` to parse, minify, and transpile CSS code for specific browser targets, including generating source maps and enabling modern CSS drafts like nesting and custom media queries. It also shows a basic custom visitor example."},"warnings":[{"fix":"Review relative color calculations, particularly within `calc()` functions. Convert percentage values to numbers where the spec now requires them.","message":"In `v1.30.0`, the parsing of relative colors was updated to align with the latest CSS specification. This change requires `calc()` expressions within relative colors to use numbers instead of percentages. Existing code that uses percentages in these contexts may need to be updated to use number values, which could break styling.","severity":"breaking","affected_versions":">=1.30.0"},{"fix":"Ensure that the host system's architecture (arm64) and libc (GNU) match the package name. If issues persist, verify Node.js version compatibility and consider installing `lightningcss` directly to let npm/yarn resolve the correct platform-specific binary.","message":"As a platform-specific native module (`lightningcss-linux-arm64-gnu`), installation can fail if the target system's architecture (ARM64) or libc (GNU) does not match, or if there are issues with Node.js ABI compatibility. While prebuilt binaries reduce the need for `node-gyp`, underlying system differences can still cause installation or runtime failures.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Prefer `import` statements if your project is ESM-native (`\"type\": \"module\"` in `package.json`). If constrained to CJS, use dynamic `import()` (e.g., `const { transform } = await import('lightningcss');`) to load the ESM module asynchronously.","message":"The `lightningcss` library is typically an ES Module (ESM). Attempting to `require()` it in a CommonJS (CJS) environment can lead to a `ERR_REQUIRE_ESM` error. While Node.js offers interop, CJS `require()` cannot directly load ESM modules.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Always install `lightningcss` as a primary dependency. Only interact with `lightningcss-linux-arm64-gnu` if you are developing against or debugging the native bindings for a specific platform.","message":"Users should install the main `lightningcss` package (`npm install lightningcss`), not the platform-specific `lightningcss-linux-arm64-gnu` directly. The main package automatically detects the environment and installs the correct native addon, ensuring broader compatibility and avoiding manual platform targeting.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Switch to ES Module `import { transform } from 'lightningcss';` if your project is ESM. If you must use CommonJS, use dynamic import: `const { transform } = await import('lightningcss');` within an `async` function or at the top level in a module that can handle `await`.","cause":"Attempting to use `require('lightningcss')` in a CommonJS module when `lightningcss` is an ES Module.","error":"ERR_REQUIRE_ESM: require() of ES Module .../node_modules/lightningcss/lib/index.js from ... not supported."},{"fix":"Ensure your Node.js version is compatible with the installed `lightningcss` binary. Try updating `lightningcss` to the latest version (`npm update lightningcss`) or reinstalling (`npm rebuild lightningcss` or `npm install --force lightningcss`) to trigger recompilation or download of the correct prebuilt binary for your current Node.js version.","cause":"A Node.js ABI (Application Binary Interface) mismatch. The native addon was compiled for a different Node.js major version or runtime environment than the one currently being used.","error":"Error: The module '.../node_modules/lightningcss-linux-arm64-gnu/lightningcss.node' was compiled against a different Node.js version. Using Node.js X.Y.Z, expected Z.Y.X."},{"fix":"First, ensure `lightningcss` is correctly installed by running `npm install lightningcss`. If the error persists, check your system logs for detailed installation failures. Verify your system matches the `arm64` architecture and `gnu` libc. If running in a Docker container or unusual environment, try explicitly setting `NPM_CONFIG_PLATFORM` and `NPM_CONFIG_ARCH` during installation.","cause":"The native addon binary for `lightningcss` could not be found or loaded. This usually means the `lightningcss` package (or its platform-specific variant) failed to install correctly, or the system architecture/OS is incompatible.","error":"Cannot find module 'lightningcss-linux-arm64-gnu/lightningcss.node'"}],"ecosystem":"npm","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"lightningcss","cli_version":null}