Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
1 task done
iamrobert opened this issue Feb 21, 2025 · 0 comments
Open
1 task done

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

iamrobert opened this issue Feb 21, 2025 · 0 comments
Labels

Comments

@iamrobert
Copy link

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
@iamrobert iamrobert added the bug label Feb 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant