Installation

This guide will walk you through installing UnCSS for both command-line and programmatic use.

Prerequisites

Before you begin, ensure you have Node.js installed on your system. UnCSS requires Node.js version 12.0 or higher, as specified in the project's package.json.

// package.json
"engines": {
    "node": ">=12.0"
}

You can check your Node.js version by running:

node -v

Global Installation (CLI)

For using UnCSS as a command-line tool directly from your terminal, it's best to install it globally.

npm install -g uncss

Once installed, you can verify the installation by running:

uncss --version

This will give you access to the uncss command from anywhere in your system. See the Command-Line Interface guide for usage details.

Local Installation (Programmatic Use)

If you plan to use UnCSS as part of your project's build process (e.g., with PostCSS or directly in a Node.js script), you should install it as a local dependency.

Navigate to your project's root directory and run:

npm install uncss --save-dev

This will add UnCSS to your project's devDependencies in package.json.

// package.json
"devDependencies": {
    "uncss": "^0.17.3"
}

You can then use it in your scripts as shown in the Programmatic Usage guide.