I’m using Hhugo to create my own personal webpage (CV style) and created my own theme. I’m using TailwindCSS as the CSS framework. I first started the page on Windows with Hugo 82.1 and NodeJS 14.16.1 and everything worked fine. PostCSS is called without errors.
But when running the code on Ubuntu 20.04, I get the error TypeError: Object.entries(...).flatMap is not a function
I found out that this is beacuse the NodeJS version was outdated and deinstalled it and installed Node 14.16.1. However, when running hugo server, PostCSS is called with the old NodeJS version and an error is thrown.
So my question: Is there a possibility to define which NodeJS-version needs to be called over Hugo (like specifying the path to Node)?
Please note that running node -v returns v14.16.1 but when I add console.error('Node version: ', process.version); above the code that throws the error, I can see that PostCSS is called with Node v10.19.0
So Hugo seems to call another binary, but I wasn’t able to find out where this is defined.
Interesting that the old version is being picked up.
If you run which -a node that should list the location of each nodejs install. In the meantime, you could remove the old installs, so that the only one on your PATH is the correct one.
Thank you very much for your replies.
I listed all the nodejs-installations as @zwbetz suggested and it returned 3 binaries. However, all of them are version 14.16.1 ("/usr/bin/node -v", “/bin/node -v”, “/usr/local/bin/node -v”).
I also checked the wrapper (@bep), and it actually does contain #!/usr/bin/env node. Checking the version on it ("/usr/bin/env node -v") also returns v14.16.1. After placing the console.error('Node version: ', process.version); in the postcss wrapper and running hugo server, Hugo still prints v10.19.0.
However, when I execute the wrapper directly over ./postcss, it prints v14.16.1. From this I assume that the wrapper is called in another javascript-file and the first line is ignored.
I really get the feeling that there is a node binary included in Hugo… I will check afterwards if I get the same problem on another Linux system
Yes, I did… And that seems to have been the problem. Thank you!
I placed a Hugo binary in my project folder and started the server with ./hugo server and it worked.
But I’m still wondering: Why? And where does this old Node-version come from?