Troubleshooting

POSTCSS CLI

1Error: Error building site: POSTCSS: failed to transform "hb/scss/index.css" (text/css). Check your PostCSS installation.

The error above will appear if there isn’t POSTCSS CLI installed on your environment.

Fix it via the following command.

1sudo npm i -g postcss-cli

RTLCSS

1POSTCSS: failed to transform "hb/scss/index.rtl.css" (text/css): Plugin Error: Cannot find package 'rtlcss' imported from /usr/lib/node_modules/postcss-cli/index.js'

The error above will be reached if there isn’t RTLCSS installed on your machine.

Fix this error by

1sudo npm i -g rtlcss

PurgeCSS Configuration

1Error: Error building site: POSTCSS: failed to transform "hb/scss/index.css" (text/css): Error: Failed to parse runtime PurgeCSS config: Error: ENOENT: no such file or directory, open './public/.build/purgecss.json'.
2Please enable the "--renderToDisk" if you are using Hugo server.

It happens on the case of using Hugo server on production mode without the --renderToDisk flag. Fixed by appending the --renderToDisk flag.

1hugo server -e production --renderToDisk

Hugo Stats File

1Error: Error building site: POSTCSS: failed to transform "hb/scss/index.css" (text/css): /home/razonyang/Projects/razonyang/hb/purgecss.config.js:5
2        throw new Error('Hugo stats file not found, please enable the "build.writeStats".')
3        ^
4Error: Hugo stats file not found, please enable the "build.writeStats".
1build:
2  writeStats: true

Autoprefixer

1Error: Error building site: POSTCSS: failed to transform "hb/scss/index.css" (text/css): Error: Cannot find module '/usr/lib/node_modules/autoprefixer'
1sudo npm i -g autoprefixer

POSTCSS PurgeCSS

1Error: Error building site: POSTCSS: failed to transform "hb/scss/index.css" (text/css): Error: Cannot find module '@fullhuman/postcss-purgecss'
1sudo npm i -g @fullhuman/postcss-purgecss