Hugo: Postcss error with snap install of Hugo 0.70

Created on 15 May 2020  Â·  10Comments  Â·  Source: gohugoio/hugo

What version of Hugo are you using (hugo version)?

$ hugo version
Hugo Static Site Generator v0.70.0/extended linux/amd64 BuildDate: 2020-05-13T17:30:34Z

Does this issue reproduce with the latest release?

Yes.

Environment

$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 20.04 LTS
Release:        20.04
Codename:       focal

To Reproduce the Issue

git clone --single-branch -b hugo-github-issue-7278 https://github.com/jmooring/hugo-testing hugo-github-issue-7278
cd hugo-github-issue-7278
npm ci
/snap/bin/hugo
`npm ci` is required to locally install poscss-cli and autoprefixer. ### Details
Building sites … /home/jmooring/temp/hugo-gh-issue-7278/node_modules/fs-extra/lib/mkdirs/make-dir.js:86
      } catch {
              ^

SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object. (/home/jmooring/temp/hugo-gh-issue-7278/node_modules/fs-extra/lib/mkdirs/index.js:3:44)
ERROR 2020/05/15 08:46:32 POSTCSS: failed to transform "sass/main.css" (text/css): /home/jmooring/temp/hugo-gh-issue-7278/node_modules/fs-extra/lib/mkdirs/make-dir.js:86
      } catch {
              ^

SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object. (/home/jmooring/temp/hugo-gh-issue-7278/node_modules/fs-extra/lib/mkdirs/index.js:3:44)
Total in 185 ms
Error: Error building site: failed to render pages: render of "page" failed: "/home/jmooring/temp/hugo-gh-issue-7278/layouts/_default/baseof.html:9:14": execute of template failed: template: _default/single.html:9:14: executing "_default/single.html" at <$style.Content>: error calling Content: POSTCSS: failed to transform "sass/main.css" (text/css): /home/jmooring/temp/hugo-gh-issue-7278/node_modules/fs-extra/lib/mkdirs/make-dir.js:86
      } catch {
              ^

SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object. (/home/jmooring/temp/hugo-gh-issue-7278/node_modules/fs-extra/lib/mkdirs/index.js:3:44)

Most helpful comment

For the workarounds, using hugo binary from github release.

sudo snap remove hugo
mkdir hugobin
cd hugobin
curl -L https://github.com/gohugoio/hugo/releases/download/v0.74.3/hugo_extended_0.74.3_Linux-64bit.tar.gz | tar -xz
sudo mv hugo /usr/local/bin/hugo
cd ..
rm -r hugobin

All 10 comments

It seems to have something to do with parameterless catch statements in the newest version of node-fs-extra.
This is a new feature only available in nodejs since 10.3.

https://github.com/jprichardson/node-fs-extra/blob/master/lib/mkdirs/make-dir.js#L85

My Node version is 12.16.2 and still happens. Any workarounds?

Also reproducible with snap installation of Hugo Static Site Generator v0.71.1/extended linux/amd64 BuildDate: 2020-05-25T13:06:06Z.

Also reproducible with snap installation of Hugo Static Site Generator v0.72.0/extended linux/amd64 BuildDate: 2020-05-31T18:10:04Z

For the workarounds, using hugo binary from github release.

sudo snap remove hugo
mkdir hugobin
cd hugobin
curl -L https://github.com/gohugoio/hugo/releases/download/v0.74.3/hugo_extended_0.74.3_Linux-64bit.tar.gz | tar -xz
sudo mv hugo /usr/local/bin/hugo
cd ..
rm -r hugobin

Hi @jmooring,

Sorry for the late follow-up.

It seems to have something to do with parameterless catch statements in the newest version of node-fs-extra.
This is a new feature only available in nodejs since 10.3.

https://github.com/jprichardson/node-fs-extra/blob/master/lib/mkdirs/make-dir.js#L85

The current Hugo snap bundles a copy of nodejs 8.12.0, so would that be the culprit? I.e., would bundling a newer copy of nodejs in the Hugo snap fix the issue?

@anthonyfok

would bundling a newer copy of nodejs in the Hugo snap fix the issue?

I have no idea. Why don't you give it a try? See "To Reproduce the Issue" in the original issue comment.

Do we have to bundle nodejs? For a Hugo user to use PostCSS they have to install postcss-cli using npm which which requires nodejs. So they already have nodejs installed.

Do we have to bundle nodejs?

For a confinement: strict snap, I believe so. Hugo-as-a-snap cannot access the nodejs outside of the snap.

Please correct me if I am wrong though as it would make things much easier. ;-)

The fix is committed in commit 748fd4c, though admittedly I am not sure if it would solve your problem yet.

Please either:

  • wait a day or two, then install the latest the Hugo snap from the edge channel, or
  • wait until the next Hugo release (0.75.0?) when its snap is released to the stable channel.

If the issue isn't really fixed, please re-open this issue and @ me. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

artelse picture artelse  Â·  3Comments

bep picture bep  Â·  3Comments

antifuchs picture antifuchs  Â·  3Comments

moorereason picture moorereason  Â·  3Comments

vielmetti picture vielmetti  Â·  3Comments