# Choose nodejs version on Pi before installing Node-RED

**URL:** <https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317>\
**Category:** General\
**Created:** [30 October 2019 10:35 UTC](https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317 "2019-10-30T10:35:52Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![psulli10](https://avatars.discourse-cdn.com/v4/letter/p/958977/32.png) [@psulli10](https://discourse.nodered.org/u/psulli10)\
**Post date:** [30 October 2019 10:35 UTC](https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317/1 "2019-10-30T10:35:52Z")

</div>

Hi,

I'm looking for a way to set my nodejs version to version 8 that isn't nvm...

I've tried using Debian form the command line:

```auto
curl -sL https://deb.nodesource.com/setup_8.x | bash -
apt-get install -y nodejs

```

But this just installed the latest version... has anyone got any advice on how best to install an older version of node? I'm installing it to a Raspberry Pi 3.

Thanks!

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [30 October 2019 10:58 UTC](https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317/2 "2019-10-30T10:58:55Z")

</div>

Do you realise that nodes v8 is End of Life in December?

> **[Releases | Node.js](https://nodejs.org/en/about/releases/)**
>
> Node.js® is a JavaScript runtime built on Chrome's V8 JavaScript engine.

But you can download the release from the versions link onto page link above

---

<div class="post-metadata">

**Author:** ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)\
**Post date:** [30 October 2019 11:13 UTC](https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317/3 "2019-10-30T11:13:09Z")

</div>

Welcome  
Could we ask whay you are wanting to install an older version of node.js as there may be better solutions to your issue?

---

<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:** [30 October 2019 11:23 UTC](https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317/4 "2019-10-30T11:23:08Z")

</div>

You forgot `apt-get update`, but also I think you would need `apt-get remove nodejs` before installing it to get rid of the old one. In addition if your distribution has a later version in it's repositories then it will install that one. You would have to explicitly instalal the version you want and the pin it to prevent it being updated.  
However, as has already been pointed, it probably isn't a good idea anyway.

---

<div class="post-metadata">

**Author:** ![psulli10](https://avatars.discourse-cdn.com/v4/letter/p/958977/32.png) [@psulli10](https://discourse.nodered.org/u/psulli10)\
**Post date:** [30 October 2019 11:31 UTC](https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317/5 "2019-10-30T11:31:23Z")

</div>

Thanks for the welcome cymplecy. I'm using a package/node-RED node called noble to scan for BLE devices and measure tilt. Noble is awaiting a patch to work with nodejs v10 on a Pi so currently v8 is what I need to use this package/node...

---

<div class="post-metadata">

**Author:** ![psulli10](https://avatars.discourse-cdn.com/v4/letter/p/958977/32.png) [@psulli10](https://discourse.nodered.org/u/psulli10)\
**Post date:** [30 October 2019 11:33 UTC](https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317/6 "2019-10-30T11:33:26Z")

</div>

Hi ukmoose. Yeah I'm aware that it's no longer supported from Jan but the package I'm using (noble) is awaiting a patch to work with nodejs v10 on a Pi so I'm going to have to persevere with v8 until that happens...

---

<div class="post-metadata">

**Author:** ![psulli10](https://avatars.discourse-cdn.com/v4/letter/p/958977/32.png) [@psulli10](https://discourse.nodered.org/u/psulli10)\
**Post date:** [30 October 2019 11:36 UTC](https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317/7 "2019-10-30T11:36:35Z")

</div>

Thanks Colin. I'm running the Debian script from a band new flash of Raspbian Buster Lite so assumed that as no version of nodejs was present that it would pin which ever version I had pointed at. I'm going to try a manual install but will also try using `apt-get remove nodejs` before I try another install using the Debian approach...

---

<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:** [30 October 2019 11:50 UTC](https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317/8 "2019-10-30T11:50:44Z")

</div>

I am pretty sure that Buster will have a version of nodejs \> 8.x in its repository. The result is that when you add the nodesource for version 8 that apt will see both the 8.x version in the nodesource repo and the later version in the Buster repo. When you install the default (which is sensible) is to use the latest version from any configured source, which will be the Buster one. So to install v8 you have not only to provide the nodesource repository but also to explicitly install that version. If you run  
`apt-cache policy nodejs` you will see all the versions available.

---

<div class="post-metadata">

**Author:** ![kuema](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/kuema/32/6542_2.png) [@kuema](https://discourse.nodered.org/u/kuema)\
**Post date:** [30 October 2019 13:45 UTC](https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317/9 "2019-10-30T13:45:55Z")

</div>

The current version in Buster is 10.15.2: [https://packages.debian.org/buster/nodejs](https://packages.debian.org/buster/nodejs)

However, I tend to use the Nodesource repository, they are more up to date and contain everything in a single package. The Debian version is split into many different packages (node, npm, dependencies, ...)

I use the following sources in my `/etc/apt/sources.list.d/nodesource.list`

```nohighlight
deb https://deb.nodesource.com/node_10.x buster main
deb-src https://deb.nodesource.com/node_10.x buster main

```

But be aware that these won't work on older ARMv6 SoCs like the Pi Zero!

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [30 October 2019 16:39 UTC](https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317/10 "2019-10-30T16:39:37Z")

</div>

so yes - to clean up... - remove nodejs `sudo apt-get purge nodejs`, then remove the current repository  
`sudo rm /etc/apt/sources.list.d/nodesource.list` , then refresh the apt-cache ,`sudo apt-get update`- and then redo your install nodejs 8 command from above

```auto
curl -sL https://deb.nodesource.com/setup_8.x | bash -
sudo apt-get install -y nodejs=8.16.2

```

that should get you nodejs 8  
If you already have Node-RED installed then you will also need to rebuild any nodes with binary code

```auto
cd ~/.node-red
npm rebuild

```

---

<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:** [30 October 2019 17:08 UTC](https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317/11 "2019-10-30T17:08:09Z")

</div>

> [@dceejay](#):
>
> that should get you nodejs 8

I don't think so, I think it will get version 10 from the Buster repository, since by default apt will get the latest version available from any of it's repos.

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [30 October 2019 18:33 UTC](https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317/12 "2019-10-30T18:33:30Z")

</div>

Ok you should be able to use

```auto
sudo apt-get install nodejs=8.16.2

```

after the initial curl command has run to add the nodesource repo to the list.  
(also edited above)

---

<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:** [30 October 2019 20:41 UTC](https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317/13 "2019-10-30T20:41:19Z")

</div>

> [@dceejay](#):
>
> sudo apt-get install nodejs=8.16.2

Nearly, with apt you have to use the full version id so it would be something like  
`sudo apt install nodejs=8.16.2-1nodesource1`  
the exact id would be found using `apt policy nodejs`.  
There is still more to do though, as the next time that apt upgrade is run it would upgrade it to 10.x again. The solution is to tell apt to hold the package at the current version using  
`sudo apt-mark hold nodejs`  
which would prevent it being updated. To unmark it later use  
`sudo apt-mark unhold nodejs`

---

<div class="post-metadata">

**Author:** ![psulli10](https://avatars.discourse-cdn.com/v4/letter/p/958977/32.png) [@psulli10](https://discourse.nodered.org/u/psulli10)\
**Post date:** [31 October 2019 09:52 UTC](https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317/14 "2019-10-31T09:52:27Z")

</div>

Thanks for all the feedback folks, much appreciated... 👍

I've been able to install node 8 using a combination of the advice given. The issue then arises when I run the bash script to install node-RED... on closer inspection the script looks for the current version of node at file path /usr/bin/local/node and if it either doesn't find an LTS version or one older than version 7 it defaults to installing the most recent node version. I've ran some of the individual bash commands in the terminal to check that my version of node 8 is visible to the script (which it is) but when I run the script it still ignores this and installs the latest version... 🤷‍♂️ I've got a local solution in that a colleague has an image of node 8 and Raspian Jessie which lets me move forward but may not be a long term solution unfortunately...

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [31 October 2019 11:27 UTC](https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317/15 "2019-10-31T11:27:38Z")

</div>

You could download the script an comment out the nodejs lines.

But the long term solution is for the contrib node to be 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:** [31 October 2019 14:58 UTC](https://discourse.nodered.org/t/choose-nodejs-version-on-pi-before-installing-node-red/17317/16 "2019-10-31T14:58:24Z")

</div>

If forcing a version of nodejs I think it would be better not to use the script. Install node-red manually in the normal way.
