# Updating systemd node version

**URL:** <https://forum.ghost.org/t/updating-systemd-node-version/41729>\
**Category:** Developer help\
**Created:** [October 8, 2023, 10:13pm UTC](https://forum.ghost.org/t/updating-systemd-node-version/41729 "2023-10-08T22:13:43Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![PhilH](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@PhilH](https://forum.ghost.org/u/PhilH)\
**Post date:** [October 8, 2023, 10:13pm UTC](https://forum.ghost.org/t/updating-systemd-node-version/41729/1 "2023-10-08T22:13:43Z")

</div>

Upgrading node and uninstalling old version does not update what Ghost is using in systemd

Ghost one-click from DigitalOcean is still using Node 16.17.0  
Upgrading to latest 18.xx version and removing 16.17.0 via nvm

Checking system Node.js version - found v16.17.0

Question: Where is Ghost’s systemd config located?

---

<div class="post-metadata">

**Author:** ![markstos](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/markstos/32/18182_2.png) [@markstos](https://forum.ghost.org/u/markstos)\
**Post date:** [October 9, 2023, 1:47am UTC](https://forum.ghost.org/t/updating-systemd-node-version/41729/2 "2023-10-09T01:47:40Z")

</div>

/lib/systemd/system/

---

<div class="post-metadata">

**Author:** ![PhilH](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@PhilH](https://forum.ghost.org/u/PhilH)\
**Post date:** [October 9, 2023, 3:07am UTC](https://forum.ghost.org/t/updating-systemd-node-version/41729/3 "2023-10-09T03:07:13Z")

</div>

Thanks  
I had looked at that previously but did not see anything obvious to change.

```auto
[Unit]
Description=Ghost systemd service for blog: www-rvingpros-com
Documentation=https://ghost.org/docs/

[Service]
Type=simple
WorkingDirectory=/var/www/ghost
User=997
Environment="NODE_ENV=production"
ExecStart=/usr/bin/node /usr/bin/ghost run
Restart=always

[Install]
WantedBy=multi-user.target

```

---

<div class="post-metadata">

**Author:** ![PhilH](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@PhilH](https://forum.ghost.org/u/PhilH)\
**Post date:** [October 9, 2023, 3:12am UTC](https://forum.ghost.org/t/updating-systemd-node-version/41729/4 "2023-10-09T03:12:00Z")

</div>

> [@PhilH](#):
>
> `Environment="NODE_ENV=production"`

Looking for info on forcing an update to NODE\_ENV=production

---

<div class="post-metadata">

**Author:** ![markstos](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/markstos/32/18182_2.png) [@markstos](https://forum.ghost.org/u/markstos)\
**Post date:** [October 9, 2023, 5:25pm UTC](https://forum.ghost.org/t/updating-systemd-node-version/41729/5 "2023-10-09T17:25:29Z")

</div>

What does `/usr/bin/node --version` return?

And `dpkg -l 'node*'`?

You should not modify files under `/lib` in any case-- that directory is reserved for vendor packages.

If want to customize this file, you can install a replacement in `/etc/systemd/system/` and it will be prioritized.

Even better, search for “drop-in” in this file: [systemd.unit](https://www.freedesktop.org/software/systemd/man/systemd.unit.html)

You can create a “drop-in” directory under /etc/systemd/system and add a config file that overrides just the values you want to modify from `/lib`.

This way, your changes would survive an upgrade or re-install of Ghost.

> [@PhilH](#):
>
> Looking for info on forcing an update to NODE\_ENV=production

Why would you want change this value in production to something else?

---

<div class="post-metadata">

**Author:** ![PhilH](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@PhilH](https://forum.ghost.org/u/PhilH)\
**Post date:** [October 9, 2023, 5:44pm UTC](https://forum.ghost.org/t/updating-systemd-node-version/41729/6 "2023-10-09T17:44:07Z")

</div>

```auto
root@ghost2:~# node -v
v18.18.0

root@ghost2:~# /usr/bin/node --version
v16.17.0

root@ghost2:~# dpkg -l 'node*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name Version Architecture Description
+++-==============-========================-============-======================>
ii nodejs 16.17.0-deb-1nodesource1 amd64 Node.js event-based se>
un nodejs-dev <none> <none> (no description availa>
un nodejs-doc <none> <none> (no description availa>
un nodejs-legacy <none> <none> (no description availa>

```

> [@markstos](#):
>
> Why would you want change this value in production to something else?

I stated this poorly… looking to force the use of latest 18.xx as version used in NODE\_ENV=production

---

<div class="post-metadata">

**Author:** ![markstos](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/markstos/32/18182_2.png) [@markstos](https://forum.ghost.org/u/markstos)\
**Post date:** [October 9, 2023, 6:00pm UTC](https://forum.ghost.org/t/updating-systemd-node-version/41729/7 "2023-10-09T18:00:19Z")

</div>

Thanks.

I missed on the first pass your mention of `nvm` as your upgrade method.

As you can see from testing some system versions, Node 16 is still installed and `/usr/bin/node` – the one that Ghost uses – uses is still version 16.

NVM is not really meant as a system package manager because it works by modifying environment variables that are only set in your current shell-- and those changes don’t apply to systemd units.

First, I would question why you are upgrading Node, since Node 16 is supported and is working fine.

But if you want to upgrade Node, I would recommend the `n` version manager, which you can install from NPM. To use it, the syntax would be like `sudo n 18`.

It will install a new node in `/usr/local/bin/node`

From there, you can use a method I described previously to create a new Ghost systemd unit file that replaces `/usr/bin/node` with `/usr/local/bin/node` OR you can remove /usr/bin/node and symlink it to /usr/local/bin/node. If you do that, you are messing a file with managed by the `nodejs` package, and it may complain if you uninstall or upgrade the `nodejs` package later.

Oh look, there’s some official documentation about using `nvm`:

> **[Using nvm with local and production Ghost installs](https://ghost.org/docs/faq/using-nvm/)**
>
> Find out how to use nvm with local and production Ghost installs in the Ghost developer guides.

It seems to recommend that’s OK to use `nvm`, but to symlink the Node binary that NVM installs to `/usr/bin/node`, but I would recommend just using `n` instead.

---

<div class="post-metadata">

**Author:** ![PhilH](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@PhilH](https://forum.ghost.org/u/PhilH)\
**Post date:** [October 11, 2023, 4:40pm UTC](https://forum.ghost.org/t/updating-systemd-node-version/41729/8 "2023-10-11T16:40:24Z")

</div>

Thanks for the education on NVM vs n. I understood this much differently.  
The hoops/steps to change Node version are significant. I am thinking it would be better or at least a bit easier to deploy new server that is already using the desired Node version then migrating the Ghost site to new server.

> [@markstos](#):
>
> First, I would question why you are upgrading Node, since Node 16 is supported and is working fine.

Yes, 16 is working fine but 18.xx is current supported version. Whether one upgrades Node now or later eventually it would be less of an optional thing. Upgrading is a certainty at some point. May as well learn the in and outs of doing so now.  
FYI: I think Ghost folks have updated DigitalOcean one-click but the old version is still being deployed as of a couple of days ago.

BTW: Difficulty udpgrading Node is what lead to [Installation Errors Using Official Doc](https://forum.ghost.org/t/installation-errors-using-official-doc/41691/1)

---

<div class="post-metadata">

**Author:** ![markstos](https://sea1.discourse-cdn.com/flex015/user_avatar/forum.ghost.org/markstos/32/18182_2.png) [@markstos](https://forum.ghost.org/u/markstos)\
**Post date:** [October 11, 2023, 7:18pm UTC](https://forum.ghost.org/t/updating-systemd-node-version/41729/9 "2023-10-11T19:18:23Z")

</div>

@PhilH,

@RyanF pointed out to me that Node has updated official documentation on how to upgrade Node using operating system packages:

> **[How to migrate to the new repository](https://github.com/nodesource/distributions/wiki/How-to-migrate-to-the-new-repository)**
>
> NodeSource Node.js Binary Distributions. Contribute to nodesource/distributions development by creating an account on GitHub.

This is a way to upgrade from Node 16 to 18 that may be even better than using either `nvm` or `n` for the task.

And you are right-- now that Node 16 is being EOL’ed, that’s a good reason to upgrade!

---

<div class="post-metadata">

**Author:** ![PhilH](https://avatars.discourse-cdn.com/v4/letter/p/7ab992/32.png) [@PhilH](https://forum.ghost.org/u/PhilH)\
**Post date:** [October 12, 2023, 4:02am UTC](https://forum.ghost.org/t/updating-systemd-node-version/41729/10 "2023-10-12T04:02:18Z")

</div>

@markstos and @RyanF Thank you!

Started a fresh instance of Ghost One-click but the installer is now installing v18.17.1  
The instructions from Nodesource were a snap for upgrading to Node v18.18.1. Should make keeping Node current a snap.

Maybe post or tag would be helpful for others. DigitalOcean Ghost 1-Click
