Categories
Servers

Updating Node on a Forge VPS

Forge publish a cookbook recipe for that here. The problem I had was my site uses website isolation, and that user didn’t have sudo access.

I was able to upgrade node (to v20 at the time of writing) by logging into the server as the root user. Ran the commands that Forge suggests, but without sudo since we were already root.

apt-get update --allow-releaseinfo-change &&  apt-get install -y ca-certificates curl gnupg

mkdir -p /etc/apt/keyrings

curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key |  gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
NODE_MAJOR=20

echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" |  tee /etc/apt/sources.list.d/nodesource.list

apt-get update --allow-releaseinfo-change &&  apt-get install nodejs -y

That version of node seems to have flowed through to my isolated website user.