If you think Hugo's error messages are ... suboptimal

0.20220302165412-259c65c8d5b8/content/site/en/showcase/letsencrypt/index.md:12:1"
Error: Error building site: POSTCSS: failed to transform "css/styles.css" (text/css): SyntaxError: Unexpected token (90:0)
    at _class.pp$4.raise (/Users/bep/dev/go/gohugoio/gohugoioTheme2/node_modules/acorn/dist/acorn.js:2927:15)
    at _class.pp.unexpected (/Users/bep/dev/go/gohugoio/gohugoioTheme2/node_modules/acorn/dist/acorn.js:698:10)
    at _class.pp$3.parseIdent (/Users/bep/dev/go/gohugoio/gohugoioTheme2/node_modules/acorn/dist/acorn.js:2878:12)
    at _class.parseIdent (/Users/bep/dev/go/gohugoio/gohugoioTheme2/node_modules/acorn-node/lib/class-fields/index.js:63:47)
    at _class.parseIdent (/Users/bep/dev/go/gohugoio/gohugoioTheme2/node_modules/acorn-node/lib/static-class-features/index.js:132:55)
    at _class.pp$3.parsePropertyName (/Users/bep/dev/go/gohugoio/gohugoioTheme2/node_modules/acorn/dist/acorn.js:2686:107)
    at _class.pp$3.parseProperty (/Users/bep/dev/go/gohugoio/gohugoioTheme2/node_modules/acorn/dist/acorn.js:2613:10)
    at _class.pp$3.parseObj (/Users/bep/dev/go/gohugoio/gohugoioTheme2/node_modules/acorn/dist/acorn.js:2567:23)
    at _class.pp$3.parseExprAtom (/Users/bep/dev/go/gohugoio/gohugoioTheme2/node_modules/acorn/dist/acorn.js:2302:19)
    at _class.parseExprAtom (/Users/bep/dev/go/gohugoio/gohugoioTheme2/node_modules/acorn-node/lib/dynamic-import/index.js:77:117) {
  pos: 1946,
  loc: Position { line: 90, column: 0 },
  raisedAt: 1948
}

I had the above error thrown at me in a Tailwind project. To cut a long story short, the cause of it was a syntax error in tailwind.config.js. Would you have guessed?

2 Likes

Me no, I’m going to start from the beginning, debugging each tool until, after a few hours, I find the real problem.

However, I believe that the majority of Hugo internal issues that aren’t caused by a third-party program like Tailwind are usually quite informative and include a link to a page with more information.

When a project involves external dependencies or tools like Tailwind, Hugo may display unrelated issues or a long list for a minor issue.

Thanks

When I first used Hugo, I was immediately amazed by the error output. My initial reaction was “Wow, that was very informative and useful, I can quickly find what and where the problem is”.

4 Likes

It’s not always the case, but when I see a Hugo error in the console where I cannot “click on the filename” to get to the problem", I try find a way to fix that if possible.

I haven’t always seen the value of good error messages/stack traces, but it’s a real timesaver, and an area I will claim that Hugo does slightly better than most of the Node based tools out there. The JavaScript stack traces are often a mystery where I have to Google it and find “the answer” on StackOverflow.

5 Likes