#1326·purgecss

[Bug]: PurgeCSS ESM Loader Fails on Windows Drive Letters

Author: iamrobertCreated Feb 21, 2025Updated Jan 2, 2026
Labelsbug

Describe the bug

When using PurgeCSS 7.x (ESM) on Windows, running purgecss --config some-path\purgecss.config.js throws an error about "Only URLs with a scheme in: file, data, and node are supported by the default ESM loader".

Specifically, Node sees D: as a custom protocol, which PurgeCSS doesn't handle, resulting in Received protocol 'd:'.

To Reproduce

  1. Install PurgeCSS v7 (Globally or Locally):
bash
npm install -g purgecss@latest
# or locally
npm install --save-dev purgecss@latest
  1. Place a purgecss.config.js in D:\projects\my-site\.

  2. Attempt:

purgecss --config .\purgecss.config.js

Expected Behavior

PurgeCSS should load the config file without error, just as in older versions.

What I've Tried

  • Renaming the config to .cjs or .mjs
  • Using export default vs module.exports
  • Using relative paths, absolute paths, and file:///D:/...
  • Defining "type": "commonjs" in package.json
  • Installing PurgeCSS locally and calling via npx

All approaches result in the same error on Windows. The only workaround is to downgrade to PurgeCSS 4.1.3 (pre-ESM).

Environment

  • Windows 11
  • Node.js v20.x
  • PurgeCSS v7.x.x (Global or Local Installation)
  • Drive-based path (e.g., D:\projects\my-site\purgecss.config.js)

Add any other context about the problem here

Workarounds

Downgrade to PurgeCSS 4.1.3

bash
npm uninstall purgecss
npm install --save-dev [email protected]

A fix in PurgeCSS’s CLI to handle Windows drive letters would help.

Code of Conduct

  • I agree to follow this project's Code of Conduct