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
- Install PurgeCSS v7 (Globally or Locally):
npm install -g purgecss@latest
# or locally
npm install --save-dev purgecss@latest
-
Place a purgecss.config.js in D:\projects\my-site\.
-
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
Describe the bug
When using PurgeCSS 7.x (ESM) on Windows, running purgecss
--config some-path\purgecss.config.jsthrows 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
Place a
purgecss.config.jsinD:\projects\my-site\.Attempt:
purgecss --config .\purgecss.config.jsExpected Behavior
PurgeCSS should load the config file without error, just as in older versions.
What I've Tried
All approaches result in the same error on Windows. The only workaround is to downgrade to PurgeCSS 4.1.3 (pre-ESM).
Environment
Add any other context about the problem here
Workarounds
Downgrade to PurgeCSS 4.1.3
A fix in PurgeCSS’s CLI to handle Windows drive letters would help.
Code of Conduct