Skip to content

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

Description

@iamrobert

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):
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

npm uninstall purgecss
npm install --save-dev purgecss@4.1.3

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions