Which JavaScript package manager do you use with Hugo?

I maintain a Docker image for Hugo geared towards building in a CI environment such as CircleCI or Travis CI. The goal of this image is to provide a minimal set of tools and to keep the image size as small as possible. Thus it’s Alpine based.

Someone opened a GitHub Issue requesting npm be pre-installed into the image. Personally, I’m hesitate to do so because what I like about Hugo is the single dependencies and streamline-ness (not a word I know) of it. Since I’d like people other than myself to use and benefit from the image, I decided to do a poll to determine the need for such a tool in this image.

Which JavaScript package manager do you use with Hugo?

  • npm v5.x.x
  • npm v6.x.x
  • Yarn v1.3 - v1.7
  • Yarn v1.9+
  • none

0 voters

My idea is, if either npm or yarn get a significant amount of the votes, I guess I’ll pre-install that package manager. If none gets most of the votes, I’ll leave the image as is. If npm and yarn are almost equal, maybe I’ll install both but they do the same thing and, in my opinion, Yarn is better so maybe I’d just pre-install that one.

Any thoughts you’d like to share? Please feel free to do so here.

I use Yarn for my dev dependencies, but these are added to my gitignore to keep the repo clean and lean.

I currently use CodeKit to compile SCSS and concat / minimise my JS.

With Hugo pipes now being able to do all this it would be nice to drop codekit. I depend on the convenience of vendor prefixes, which requires post css cli for Hugo pipes.

I could in theory install node JS, npm and then post css cli using your Docker image when deploying changes using circle ci, however I’m certain this’ll increase build time somewhat. What’s your thoughts?

P.S it was me that made the request :slight_smile:

The problem with including npm would be the speed at which it updates. If you are going to do it, I would strongly recommend using an LTS version, preferably whatever comes with the latest LTS version of Node.JS which is primarily what drives development of npm anyway. Just be ready to have to update it every time there is a Hugo update and more often if Hugo development ever slows down.

You would doubtless need to look at why the user has requested npm. Though I sympathise since I tend to use npm as a script runner simply because that’s what I know best and I always know that my dev PC will have Node.JS installed.

Personally I steer clear of Yarn simply because it isn’t aligned directly to Node.JS, it merely becomes another 3rd party tool to maintain. If I have Node.JS, I already have npm. And I only need to update Node.JS, npm comes along for the ride.

Just thought I’d add to my original comment…

The request for npm is purely for the sake of being able to install post css cli, which is required by Hugo pipes for vendor prefixes when processing our css.

I’m an advocate for keeping the Docker image as lean as possible, but I do feel without adding post css cli the image can only partly cater to its user base (ie those who chose not to use Hugo pipes and those who do but don’t require css vendor prefixes).

Is there a way to include post css cli binary without needing to add npm?

I believe having it included just means npm is available from the beginning, without installing it. In theory you could install npm and any packages in your build script. If your build system uses certain kinds of image-caching that might not be an issue.

I’ll let this poll run for another week but so far it looks like keeping the Docker image as-is, not installing npm or Yarn, is going to be the way to go.