I tried installing the latest version of Ghost on my DigitalOcean one-click droplet from last year and received the following error:
✖ Downloading and updating Ghost to v5.73.0
A SystemError occurred.
Message: Ghost v5.73.0 is not compatible with the current Node version. Your node version is 16.20.2, but Ghost v5.73.0 requires ^18.12.1
Debug Information:
OS: Ubuntu, v22.04.3 LTS
Node Version: v16.20.2
Ghost Version: 5.68.0
Ghost-CLI Version: 1.25.2
Environment: production
Command: 'ghost update'
I also noticed the latest one-click image has Node.js v18 already installed. Is there a “right” way to upgrade a DigitalOcean droplet to the latest image to get this to work? I assume it may also contain updated PostgreSQL and other packages.
Are you trying to update Ghost? Which version of Ghost you are currently using? It seems that Node 18.12.1 already installed? More context of your environment and what you are trying to achieve will be helpful.
Turns out the answer was a little more complicated. Although I’m a huge fan of nvm, I decided to go the apt route outlined in a number of articles.
Most of this is captured in Ghost.org’s Supported NodeJS Versions and Compatibility guide, but it skipped a few updates like NPM and ghost-cli, and when I tried to start the service, I received a DB connection refused error. As suggested in this article, it turned out to be a problem with NodeJS v18 preferring IPv6 vs v16 which preferred IPv4. Changing the connection string in config.production.json from localhost to 127.0.0.1 did the trick.
Here’s the complete process that worked for me (I had to restore from snapshot several times to get it right). Power off your droplet and take a snapshot before you begin!!!
# Login as ghost user
sudo -i -u ghost-mgr
cd /var/www/ghost
# Stop ghost
ghost stop
# Change database connection in ghost config from `localhost` to `127.0.0.1`
nano config.production.json
# update yarn key
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
# Download and import the Nodesource GPG key
sudo apt-get update
sudo apt-get install -y ca-certificates curl gnupg
sudo mkdir -p /etc/apt/keyrings
curl -fsSL https://deb.nodesource.com/gpgkey/nodesource-repo.gpg.key | sudo gpg --dearmor -o /etc/apt/keyrings/nodesource.gpg
# Create deb repository
NODE_MAJOR=18 # Use a supported version
echo "deb [signed-by=/etc/apt/keyrings/nodesource.gpg] https://deb.nodesource.com/node_$NODE_MAJOR.x nodistro main" | sudo tee /etc/apt/sources.list.d/nodesource.list
# Run update and install NodeJS
sudo apt-get update
sudo apt-get install nodejs -y
# Update NPM to the latest
sudo npm install -g npm@10.2.4
# Update ghost CLI to latest version
sudo npm install -g ghost-cli@latest
# Update ghost with the same version
ghost version
ghost update [version] --force # NOTE: Substitute [version] with your ghost version above
# start the service, test that it works, then stop again. If it fails here, do not proceed
# Update ghost to the latest version
ghost update