'Purgecss is not a constructor' when following the JS API examples
See original GitHub issueHi,
I’m trying to follow the ES5 JS API examples but it looks like something is going wrong with the export as I’m getting a TypeError: Purgecss is not a constructor
error. I think it’s probably something I’m doing wrong rather than a problem with the docs, but I’m not 100% sure.
This is my output from trying to run purgeCss.js
with node v8.6.0.
/usr/local/bin/node /Users/name/Sites/project/core/www/sites/all/themes/custom/project_theme/purgeCss.js
/Users/name/SItes/project/aman/core/www/sites/all/themes/custom/project_theme/purgeCss.js:2
var purgecss = new Purgecss({
^
TypeError: Purgecss is not a constructor
at Object.<anonymous> (/Users/name/Sites/project/core/www/sites/all/themes/custom/project_theme/purgeCss.js:2:16)
at Module._compile (module.js:624:30)
at Object.Module._extensions..js (module.js:635:10)
at Module.load (module.js:545:32)
at tryModuleLoad (module.js:508:12)
at Function.Module._load (module.js:500:3)
at Function.Module.runMain (module.js:665:10)
at startup (bootstrap_node.js:187:16)
at bootstrap_node.js:607:3
Process finished with exit code 1
Issue Analytics
- State:
- Created 6 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Webpack 5 - PurgeCss - Not a Constructor Error
I keep getting the error PurgeCss is not a constructor when I run Webpack. Funny enough this used to work but ever since...
Read more >purgecss - npm
Remove unused css selectors. Latest version: 5.0.0, last published: 3 months ago. Start using purgecss in your project by running `npm i ...
Read more >Eliminating Unused CSS - SurviveJS
After this you'll end up with a tailwind.config.js file at the project root. ... At best, PurgeCSS can eliminate most, if not all,...
Read more >TypeError: "X" is not a constructor in JavaScript | bobbyhadz
reject() with the new operator. typeerror is not a constructor. Here's an example of how the error occurs. index.js.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
If you are using the latest version, the API changed a bit.
If you are using with require, you should be able to import it like this:
Thanks for all your work on Purgecss @Ffloriel 😃 I’ve been using it for project at home for a while, and today I set it up on a project at work too.