Issue with running Hugo project due to TOCSS-DART error when using Sass and Dart on macOS

Hi!

Problem Description: When attempting to run a Hugo project on my macOS device using the hugo command, the following error occurs:

Error: error building site: TOCSS-DART: failed to transform “sass/main.scss” (text/x-scss): got unexpected EOF when executing “sass”. The user running hugo must have read and execute permissions on this program. With execute permissions only, this error is thrown.

Attempting to install Sass and Dart using the brew install sass/sass/sass command also results in an AOT compilation error:

==> /opt/homebrew/opt/dart/libexec/bin/dart compile exe -Dversion=1.70.0 -Dcompiler-version=1.70.0 -Dprotocol-version=2.5.0 bin/sass.dart -o sass

lib/src/embedded/compilation_dispatcher.dart:213:22: Error: The type ‘InboundMessage_CompileRequest_Importer_Importer’ is not exhaustively matched by the switch cases since it doesn’t match ‘InboundMessage_CompileRequest_Importer_Importer.nodePackageImporter’.

  • ‘InboundMessage_CompileRequest_Importer_Importer’ is from ‘package:sass/src/embedded/embedded_sass.pb.dart’ (‘lib/src/embedded/embedded_sass.pb.dart’).
    Try adding a default case or cases that match ‘InboundMessage_CompileRequest_Importer_Importer.nodePackageImporter’.
    switch (importer.whichImporter()) {
    ^
    Error: AOT compilation failed
    Generating AOT kernel dill failed!

Additionally, attempting to install Node Sass using the brew install node-sass command also did not help resolve the issue.

Additional Information:

  • Version of Sass installed via npm: 1.70.0
  • Hugo version: v0.122.0-b9a03bd59d5f71a529acb3e33f995e0ef332b3aa+extended darwin/arm64 BuildDate=2024-01-26T15:54:24Z VendorInfo=brew
  • Operating system: macOS
  • Output of sass --version command: 1.70.0 compiled with dart2js 3.2.5
  • Output of sass --embedded --version command: sass --embedded is unavailable in pure JS mode.
  • Attempted to install Sass via npm, but the problem was not resolved.
  • Tried specifying the path to the Sass executable file in the Hugo configuration file, but this also

❯ hugo env
hugo v0.122.0-b9a03bd59d5f71a529acb3e33f995e0ef332b3aa+extended darwin/arm64 BuildDate=2024-01-26T15:54:24Z VendorInfo=brew
GOOS=“darwin”
GOARCH=“arm64”
GOVERSION=“go1.21.6”
sass --embedded is unavailable in pure JS mode.
github.com/sass/libsass=“3.6.5”
github.com/webmproject/libwebp=“v1.3.2”




If you search this forum for “TOCSS-DART” you will find:

https://discourse.gohugo.io/t/error-building-site-tocss-dart/48047/12

The Node.js Dart Sass implementation specifically excludes this capability, which is why this installation method is not listed in the Hugo documentation.

If I were you I would uninstall all instances of Dart Sass, cleanup my Brew cache, and install Dart Sass with Brew. Any problems you’re having with Brew are Brew problems, not Hugo or Dart Sass problems. The Brew installation method works great.

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