# Updating, nodejs, and other things

**URL:** https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479
**Category:** General
**Created:** [10 August 2023 22:11 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479 "2023-08-10T22:11:47Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [10 August 2023 22:11 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/1 "2023-08-10T22:11:47Z")

</div>

Sorry folks, I know this is a _well traveled road_.

Most of my machines I use a lot are up to date with NR 3.x.

Lately I've dug up some older machines and they have NR 1.8x on them. (RasPies too.)

And the machine is running .... Jessie I believe.  
So node.js is OLD too.

What's happening is I am exporting things from the main machines to them and getting errors. Of course.

So I try to update but am told the node.js is no longer supported (or something like that) and it would be nice to update NR to 3.x

Yes, I get that this means a bit of work on my part.  
An update of the O/S would be even better.

So my question is - I hope as briefly as possible:  
Can I update to a later node.js than what is used by NR 1.x WITHOUT updating the O/S?

I get it that if that can't be done I really only have 2 choices. Leave alone or update the whole thing.  
Just thought I would ask to establish the first part.

Thanks.

---

<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: [10 August 2023 23:04 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/2 "2023-08-10T23:04:36Z")

</div>

> [@Trying\_to\_learn](#):
>
> Can I update to a later node.js than what is used by NR 1.x WITHOUT updating the O/S?

Yes, you can. I don't think you'll get problems on Jesse. Just make sure all the OS libraries are up-to-date. Then either use Dave's update script or use a suitable library listed on the Node.js website.

When you've updated node.js, don't forget to do an npm rebuild on both global and your userDir folder.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [12 August 2023 09:08 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/3 "2023-08-12T09:08:49Z")

</div>

Thanks Julian.

Alas I am going through a few months of bad memory stuff.

I get part but not all of what you said. Sorry.

This is my update script:  
`bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)`

So checking the O/S libraries are up-to-date..... Lost me.

Isn't that done by the `sudo apt update`?

Then is it `npm update`? (no `sudo`)

Thanks in advance.

---

<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: [12 August 2023 10:32 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/4 "2023-08-12T10:32:42Z")

</div>

> [@Trying\_to\_learn](#):
>
> So checking the O/S libraries are up-to-date..... Lost me.
> 
> Isn't that done by the `sudo apt update`?

Not sure what is in Dave's script. But this will cover you:

```auto
sudo apt update && sudo apt upgrade
npm update -g

```

The script should do everything else anyway.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [13 August 2023 22:06 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/5 "2023-08-13T22:06:05Z")

</div>

The machine is running Stretch - not Jesse. Which is better if I remember correctly.

But I can not get node.js to update.

---

<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: [14 August 2023 06:06 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/6 "2023-08-14T06:06:51Z")

</div>

> [@Trying\_to\_learn](#):
>
> But I can not get node.js to update

What happens if you add `--node18` to the bash command? Preceded by a space of course.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [14 August 2023 06:35 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/7 "2023-08-14T06:35:31Z")

</div>

Just to clarify:

`npm update -g --node18`

From the `.node-red` directory

```auto
pi@PortaPi:~/.node-red $ npm update -g --node18
pi@PortaPi:~/.node-red $ node -v
v8.17.0
pi@PortaPi:~/.node-red $ 

```

_(someone take me out the back and shoot me)_

I am having a horrible run of bad luck with getting things working on computers just now.

---

<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: [14 August 2023 06:59 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/8 "2023-08-14T06:59:08Z")

</div>

I meant add it to the pi install script, the `bash <(curl ...` command.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [14 August 2023 06:59 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/9 "2023-08-14T06:59:47Z")

</div>

Sorry. My bad.

So that will overcome the `node.js` version problem?

`bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --node18`

seems to be working.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [14 August 2023 07:06 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/10 "2023-08-14T07:06:35Z")

</div>

All done.

Looked ok.

But....

```auto
pi@PortaPi:~/.node-red $ node-red
/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/empty/index.js:13
  } catch {
          ^

SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/index.js:8:6)
pi@PortaPi:~/.node-red $ 

```

Won't run.  
☹

Oh, this may be a reason:

```auto
pi@PortaPi:~/.node-red $ node -v
v8.17.0
pi@PortaPi:~/.node-red $ 

```

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [14 August 2023 07:21 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/11 "2023-08-14T07:21:38Z")

</div>

Searching and looking for how to update the `nodejs` part:

```auto
pi@PortaPi:~/.node-red $ sudo npm install node@16

> node@16.20.1 preinstall /home/pi/.node-red/node_modules/node
> node installArchSpecificPackage

npm ERR! code EACCES
npm ERR! syscall scandir
npm ERR! path /root/.npm/_logs
npm ERR! errno -13
npm ERR! 
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR! 
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 1000:1000 "/root/.npm"
glob error { Error: EACCES: permission denied, scandir '/root/.npm/_logs'
  errno: -13,
  code: 'EACCES',
  syscall: 'scandir',
  path: '/root/.npm/_logs' }
npm ERR! code EACCES
npm ERR! syscall open
npm ERR! path /root/.npm/_cacache/index-v5/dd/7f/965535007b5e6377646cd614059b54639208968a34ca0a0168dfef442a3d
npm ERR! errno -13
npm ERR! 
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR! 
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 1000:1000 "/root/.npm"
module.js:550
    throw err;
    ^

Error: Cannot find module 'node-linux-arm/package.json'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.resolve (internal/module.js:18:19)
    at ChildProcess.<anonymous> (/home/pi/.node-red/node_modules/node-bin-setup/index.js:19:27)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:915:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
npm WARN node-red-project@0.0.1 No repository field.
npm WARN node-red-project@0.0.1 No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node@16.20.1 preinstall: `node installArchSpecificPackage`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node@16.20.1 preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2023-08-14T07_19_25_885Z-debug.log
pi@PortaPi:~/.node-red $ 

```

So I am really confused.

Oh - P.S.  
The log file - mentioned at the end - doesn't exist.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [14 August 2023 07:23 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/12 "2023-08-14T07:23:34Z")

</div>

> [@Trying\_to\_learn](#):
>
> All done.
> 
> Looked ok.
> 
> But....

Did you update the right pi?

What did you see when the installer script ran - it tells you if node installed. Try running the script WITH ` --node18` again

Can you also run the following commands to see if you have `n` or `nvm` installed:  
`n`  
`nvm`

If either of these are installed, it may be the reason for displaying old node version.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [14 August 2023 07:30 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/13 "2023-08-14T07:30:36Z")

</div>

Ok, so on that machine:

(pictures saying 1000 words.)

 ![Screenshot from 2023-08-14 17-25-24](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/a/3a4dff20e31de783032b7f4351fcc88ccaa863d7.png)

Then it goes on:

(sorry it is taking a bit of time to run the script)

 ![Screenshot from 2023-08-14 17-28-38](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/7/9744099758db0d2e91ae0fc6f1aa5eb2c00d56fa.png)

I'll only do the `node-red` and not `node-red-start`.

```auto
pi@PortaPi:~/.node-red $ node-red
/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/empty/index.js:13
  } catch {
          ^

SyntaxError: Unexpected token {
    at createScript (vm.js:80:10)
    at Object.runInThisContext (vm.js:139:10)
    at Module._compile (module.js:617:28)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/index.js:8:6)
pi@PortaPi:~/.node-red $ 
pi@PortaPi:~/.node-red $ node -v
v8.17.0
pi@PortaPi:~/.node-red $ 

```

So `node` isn't updated.

---

<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: [14 August 2023 07:38 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/14 "2023-08-14T07:38:04Z")

</div>

What do these show?  
`which node`  
`apt policy nodejs`

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [14 August 2023 07:39 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/15 "2023-08-14T07:39:05Z")

</div>

```auto
pi@PortaPi:~/.node-red $ which node
/usr/bin/node
pi@PortaPi:~/.node-red $ apt policy nodejs
nodejs:
  Installed: 8.17.0-1nodesource1
  Candidate: 8.17.0-1nodesource1
  Version table:
 *** 8.17.0-1nodesource1 500
        500 https://deb.nodesource.com/node_8.x stretch/main armhf Packages
        100 /var/lib/dpkg/status
     8.11.1~dfsg-2~bpo9+1 500
        500 http://archive.raspberrypi.org/debian stretch/main armhf Packages
     4.8.2~dfsg-1 500
        500 http://raspbian.raspberrypi.org/raspbian stretch/main armhf Packages
pi@PortaPi:~/.node-red $ 

```

---

<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: [14 August 2023 07:39 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/16 "2023-08-14T07:39:34Z")

</div>

Also make sure that this runs without error  
`sudo apt update && sudo apt full-upgrade`

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [14 August 2023 07:40 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/17 "2023-08-14T07:40:30Z")

</div>

```auto
pi@PortaPi:~/.node-red $ sudo apt update && sudo apt full-upgrade
Hit:1 https://deb.nodesource.com/node_8.x stretch InRelease         
Hit:2 http://archive.raspberrypi.org/debian stretch InRelease                                  
Hit:3 http://raspbian.raspberrypi.org/raspbian stretch InRelease                               
Ign:4 https://q4os.org/qextrepo q4os-rpi-firefox-cn InRelease            
Err:5 https://q4os.org/qextrepo q4os-rpi-firefox-cn Release
  404 Not Found
Reading package lists... Done
E: The repository 'http://q4os.org/qextrepo q4os-rpi-firefox-cn Release' does no longer have a Release file.
N: Updating from such a repository can't be done securely, and is therefore disabled by default.
N: See apt-secure(8) manpage for repository creation and user configuration details.
pi@PortaPi:~/.node-red $ 

```

---

<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: [14 August 2023 07:44 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/18 "2023-08-14T07:44:25Z")

</div>

You need to fix that.

---

<div class="post-metadata">

### Author: ![Trying\_to\_learn](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/trying_to_learn/32/28400_2.png) [@Trying\_to\_learn](https://discourse.nodered.org/u/Trying_to_learn)
#### Post date: [14 August 2023 07:45 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/19 "2023-08-14T07:45:11Z")

</div>

Yes, but `that` is above my skill set.

All I see is that it doesn't/can't update the `firefox` part.

---

<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: [14 August 2023 07:50 UTC](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479/20 "2023-08-14T07:50:40Z")

</div>

> [@Trying\_to\_learn](#):
>
> All I see is that it doesn't/can't update the `firefox` part.

What you should see is that it has errored out and not completed, therefore nodejs cannot be updated via apt.

Look in /etc/apt/sources.list and delete the relevant line(s) if they are there (or comment them out). If not then look for a file in /etc/apt/sources.list.d/ that provides that repository and delete it (or comment out the contents). Then make sure the update && full-upgrade works, then run the script again.

[Next page](https://discourse.nodered.org/t/updating-nodejs-and-other-things/80479.md?page=2)
