I am trying to run Hugo on a production server and it keeps failing. I’ve tried all sorts now to no avail. This builds perfectly fine locally. The error I am getting is as follows:
Error: Error building site: POSTCSS: failed to transform "css/main.scss" (text/x-scss): TypeError: Object.entries(...).flatMap is not a function
I read online that Node 11 was an issue as flatMap was introduced in V12 but I’ve tried with 12/14/16 and get the same error.
Using just the postcss-cli on the server works fine so what is the Hugo command doing in the background differently that would be causing this to happen?
This also happens on a brand new fresh Digital Ocean droplet where all I’ve done is install Node, Hugo and pull the repo and try to run Hugo.
I first thought it might be something in your SCSS files and not node related. Anyway - did you delete the resources folder AFTER you changed from node 11 to 12/14/16? If not, delete that folder, because it caches things and it might have cached the part that throws errors.
Is there any difference between your local config and production config?
Last idea (without a testing repo it’s a blackbox): Delete package-lock.json and node_modules and re-rung npm install and retry. Check the versions in your package.json (I use npm-check-updates which updates the packages safely to the latest versions).
I am not sure about Digital Ocean droplets, but there are deb and rpm packages for Hugo without the need to use Snap. Check the repo releases: Release v0.83.1 · gohugoio/hugo · GitHub
One thing I forgot to mention: Did you install --channel=extended (not tested, but pretty sure that is the one) with Snap? without you might miss some parts of the pipeline system. And I remember reading recently here on the forum that the snap version comes with it’s own node packaged.
Hmm, yes, unpopular opinion here: Snap Hugo is for beginners If you can use one of the packages from the release page, depending on your system, do it. I am running on the .deb file and never had any issues (other than keeping an eye on the releases and manually installing updates, because Ubuntu packages Hugo very seldom up-to-date).
PS: “beginners” in sense of “uncomplicated” setups and requirements.