Install node libraries during deploy #24

Open
amras wants to merge 1 commits from node-support into main
Owner

This change checks if "package.json" exists.
If so, it installs node and runs npm install.

Not adding a version tag because I'm creating two pull requests asynchronously. Suggest the version is bumped after maintainer makes a call to merge one or both.

Description

I'm running a site with tailwindcss. According to hugo's docs this requires installing npm and tailwind on the build server.

Hugo generated a package.json when I did the builds locally, so I added that to the repo (and gitignored package-lock and node-modules). Just in case, I also checked and hugo does not create package.json if you're not using node. So this seems like a good discriminator: if the file exists, the site requires node libraries installed on the host. If the file doesn't exist, node can be omitted.

To make this work with parasol, I had to add a line to deploy.sh, to pull nodejs and run npm install just before building with hugo.

Potential concerns about my approach

Feel free to give feedback on these:

  • node and any libraries are re-installed/re-downloaded whenever the badger services restart. There's no persistent storage of the node cache
  • There's no version-lock for node; only for the libraries. The newest version of node (wrt the cache in the alpine image) is always downloaded when deploy.sh runs.
  • this change is invisible to the operator; they don't need to enable anything in the config, the recipe just automagically detects that node is needed.
This change checks if "package.json" exists. If so, it installs node and runs npm install. * [X] I have deployed and tested my changes * [ ] I have [updated relevant versions in `abra.sh`](https://docs.coopcloud.tech/maintainers/upgrade/#updating-versions-in-the-abrash) * [X] I have made my environment variable changes [backwards compatible](https://docs.coopcloud.tech/maintainers/upgrade/#backwards-compatible-environment-variable-changes) * [X] I ran `abra recipe lint parasol-static-site --chaos` on the PR's branch and fixed the warnings. * [ ] I have added a [release note entry](https://docs.coopcloud.tech/maintainers/upgrade/#creating-new-release-notes) *Not adding a version tag because I'm creating two pull requests asynchronously. Suggest the version is bumped after maintainer makes a call to merge one or both.* ## Description I'm running a site with tailwindcss. According to [hugo's docs](https://gohugo.io/functions/css/tailwindcss/#setup) this requires installing npm and tailwind on the build server. Hugo generated a `package.json` when I did the builds locally, so I added that to the repo (and gitignored package-lock and node-modules). Just in case, I also checked and hugo does not create `package.json` if you're not using node. So this seems like a good discriminator: if the file exists, the site requires node libraries installed on the host. If the file doesn't exist, node can be omitted. To make this work with parasol, I had to add a line to deploy.sh, to pull nodejs and run `npm install` just before building with hugo. ### Potential concerns about my approach Feel free to give feedback on these: - node and any libraries are re-installed/re-downloaded whenever the badger services restart. There's no persistent storage of the node cache - There's no version-lock for node; only for the libraries. The newest version of node (wrt the cache in the alpine image) is always downloaded when deploy.sh runs. - this change is invisible to the operator; they don't need to enable anything in the config, the recipe just automagically detects that node is needed.
amras added 1 commit 2026-11-06 22:41:07 +00:00
Hugo supports using NPM as part of its build process
 this is required for some features, e.g. tailwindcss:
 https://gohugo.io/functions/css/tailwindcss/#setup

This change checks if "package.json" exists.
If so, it installs node and runs npm install.
This pull request doesn't have enough required approvals yet. 0 of 1 approvals granted from users or teams on the allowlist.
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin node-support:node-support
git checkout node-support
Sign in to join this conversation.