Attempting to use postcss, "Failed to transform [...] (text/css) unexpected identifier" error

Hello there I’m a student struggling with this hugo pipes error. I couldn’t find solutions in this forum.
I was scripting step by step in my Head partial. I have 2 sass files which I concatenate and then convert to css. Everything below works EXCEPT for the last line which returns the following error upon running the hugo command.

hugo v0.92.1-85E2E862+extended windows/amd64 BuildDate=2022-01-27T11:44:41Z VendorInfo=gohugoio
Error: Error building site: POSTCSS: failed to transform “css/global.css” (text/css): Unexpected identifier

Here is my use of pipes

{{- $cssOpts := (dict "targetpath" "css/global.css" "outputStyle" "compressed") -}}
{{- $postOpts := (dict "config" "./postcss.config.js" "targetpath" "css/global.min.css") -}}

{{- $boilerplate := resources.Get "sass/boilerplate.sass" -}}
{{- $template := resources.Get "sass/template.sass" -}}
{{- $globalsass := slice $boilerplate $template | resources.Concat "sass/global.sass" -}}
{{- $style := $globalsass | toCSS $cssOpts -}}
{{- $style = $style | postCSS $postOpts -}}

<link rel="stylesheet" href="{{ $style.Permalink }}"  type="text/css">

Where postcss.config.js simply contains:

const autoprefixer = require('autoprefixer');

module.exports = {
  plugins: [
    autoprefixer()
  ]
};

Some things I’ve tried:
While initially I had installed hugo-extended via chocolatey on windows and the relevant postcss postcss-cli autoprefixers packages via npm globally.
I encountered the exact same errors using the hugo-extended binary and installing these packages locally, with a configured package json that included devdependancies of postcss postcss-cli and autoprefixer. No combination seems to change the error.

Please help! Any input is greatly appreciated!

Edit: Was running on an old node version, updating node completely changed the error to a solveable one.

I am not using PostCSS myself, therefore I cannot help you but it would speed things up, if you shared your project for the others in this forum to have a look and see how they can help you.

Also see the Requesting Help guidelines.

Paste the output from node --version

1 Like

Oh man, brilliant call !
I was running node 11.6
Updating has fixed this problem, or at least upgraded the problem to which there are solutions for in this forum!

Thank you so much!

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.