I made a test environment where I’m trying to use the global autoprefixer (npm install -g autoprefixer), as in the documentation, however, I’m getting the following error:
Hugo Pipe’s PostCSS requires the postcss-cli JavaScript package to be installed in the environment ( npm install -g postcss-cli ) along with any PostCSS plugin(s) used (e.g., npm install -g autoprefixer ).
The difference I see to my set up (have it in a partial css.html) is that you reference the postcss.config.js which is not necessary. PostCSS is looking for that file as default. Perhaps that causes the issue. Here’s the content of my partial css.html:
Because if the documentation says that you can use global packages, there is no need to have a package.json to manage local packages. This way I can make my project cleaner.
I take it you’ve also installed postcss-cli globally? If so, I’d guess this is a paths issue. Perhaps post your repo so someone can look at it.
As of .45 Hugo no longer required a global install of the modules, but, though it seems unlikely, there could be something amiss with using them now since that change.
For anyone else struggling with this issue I found it is a result of using node installed via nvm, whereby NODE_PATH is not set and thus globally installed modules are not requireable.
You can work around it by either installing the module locally to the project, or setting NODE_PATH manually: