# Update node and npm without breaking node-red

**URL:** <https://discourse.nodered.org/t/update-node-and-npm-without-breaking-node-red/99353>\
**Category:** General\
**Created:** [11 October 2025 17:08 UTC](https://discourse.nodered.org/t/update-node-and-npm-without-breaking-node-red/99353 "2025-10-11T17:08:10Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![haegar33](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haegar33/32/38805_2.png) [@haegar33](https://discourse.nodered.org/u/haegar33)\
**Post date:** [11 October 2025 17:08 UTC](https://discourse.nodered.org/t/update-node-and-npm-without-breaking-node-red/99353/1 "2025-10-11T17:08:10Z")

</div>

I am running on a Raspberry3 NR at V4.1 with underlaying node V18.20 which is the minimum setup.  
As I experience some instability with my Pi I consider updating node to V20 or V22. Whats the best strategy to ensure no issues with the current NR installation?

1. Using the `node red_installer.sh` script with argument --node20 ?
2. Doing the basic stuff `like npm update -g` and `npm cache clean -f`

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [11 October 2025 17:21 UTC](https://discourse.nodered.org/t/update-node-and-npm-without-breaking-node-red/99353/2 "2025-10-11T17:21:02Z")

</div>

If you installed node-red using the script, best to use the script to make changes. I believe the script does everything necessary.

If you prefer to do things by hand. Install the new version of node.js - this requires manual installation or use of one of the 3rd-party repo's for Pi's follow the instructions on the node.js website. After upgrading, you should do:

```bash
sudo apt update && sudo apt upgrade
npm rebuild -g
npm update -g
cd ~/.node-red
npm rebuild
npm update

```

Then restart node-red and reload the editor if you already have it open in a browser tab.

The `rebuild` commands will re-make compiled binary libraries using the new version of node.js and the latest c++ and header files and is important when moving to a new major version of node.js. They will do nothing if you don't have any binary libraries in use (but on a Pi, you will almost certainly have at least the serial nodes).

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [11 October 2025 18:21 UTC](https://discourse.nodered.org/t/update-node-and-npm-without-breaking-node-red/99353/3 "2025-10-11T18:21:35Z")

</div>

> [@haegar33](#):
>
> Using the `node red_installer.sh` script with argument --node20 ?

The official Raspberry Pi install script for Node-red is called  
update-nodejs-and-nodered-deb, not _node red-installer.sh_

So as long as you are referring to the official script, and you originally installed with it, that's the way to go.

I think it will update to node 20 (or 22?) without you adding those options at the end.

You should backup everything first just in case it's not a standard installation.

---

<div class="post-metadata">

**Author:** ![haegar33](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haegar33/32/38805_2.png) [@haegar33](https://discourse.nodered.org/u/haegar33)\
**Post date:** [12 October 2025 11:28 UTC](https://discourse.nodered.org/t/update-node-and-npm-without-breaking-node-red/99353/4 "2025-10-12T11:28:47Z")

</div>

Thanks for the advice:

Indeed the installer script has a different name. I was just renaming the downloaded script for a more simple name.

I did the manual update. As from V18 to 20 this is a major jump you need to download a script:

`curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -`

after that updates of nodejs and npm was as expected.  
I skipped the step `npm update` in my .node-red directory as I intentionally need some old version of node\_modules

NR V4.1 is running fine now with nodejs 20.19.5

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [12 October 2025 11:42 UTC](https://discourse.nodered.org/t/update-node-and-npm-without-breaking-node-red/99353/5 "2025-10-12T11:42:55Z")

</div>

Glad you have it working.

> [@haegar33](#):
>
> renaming the downloaded script for a more simple name.

Indeed, the official script does have a rather unwieldy name. On the occasions when I download it, I call it `nrscript`.

> [@haegar33](#):
>
> As from V18 to 20 this is a major jump you need to download a script:
> 
> `curl -sL https://deb.nodesource.com/setup_20.x | sudo -E bash -`

Just in case others are seeking how to do this, on Linux you don't _need_ to run any other script than the official one. It does all the downloads and installs in the background.

Actually there are two official scripts, one for Debian based Linux and one for distributions using `rpm` - Reg Hat & co.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 October 2025 09:30 UTC](https://discourse.nodered.org/t/update-node-and-npm-without-breaking-node-red/99353/6 "2025-10-13T09:30:15Z")

</div>

> [@haegar33](#):
>
> I did the manual update. As from V18 to 20 this is a major jump you need to download a script:

Not necessary, the script will do that for you  
`bash <(curl -sL https://github.com/node-red/linux-installers/releases/latest/download/update-nodejs-and-nodered-deb) --node20`

I recommend using 22 rather than 20. Use --node22 for that.

---

<div class="post-metadata">

**Author:** ![haegar33](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/haegar33/32/38805_2.png) [@haegar33](https://discourse.nodered.org/u/haegar33)\
**Post date:** [13 October 2025 11:14 UTC](https://discourse.nodered.org/t/update-node-and-npm-without-breaking-node-red/99353/7 "2025-10-13T11:14:39Z")

</div>

> [@Colin](#):
>
> Not necessary, the script will do that for you

This script will also reinstall node-red itself. That's not what I wanted.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 October 2025 12:40 UTC](https://discourse.nodered.org/t/update-node-and-npm-without-breaking-node-red/99353/8 "2025-10-13T12:40:17Z")

</div>

> [@haegar33](#):
>
> This script will also reinstall node-red itself. That's not what I wanted.

True, it will do that. Why does that bother you?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [11 January 2026 12:40 UTC](https://discourse.nodered.org/t/update-node-and-npm-without-breaking-node-red/99353/9 "2026-01-11T12:40:24Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
