Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Unsolved
Collapse
Discussion Forum to share and further the development of home control and automation, independent of platforms.
  1. Home
  2. Software
  3. Multi-System Reactor
  4. Help updating node.js for bare metal install
Oddness in Copy/Move of Reactions
G
Topic thumbnail image
Multi-System Reactor
[Solved] function isRuleEnabled() issue
CrilleC
Topic thumbnail image
Multi-System Reactor
[Reactor] Problem with Global Reactions and groups
therealdbT
Topic thumbnail image
Multi-System Reactor
Possible feature request 2?
CatmanV2C
Just another thought. Adding devices from my Home Assistant / Zigbee2MQTT integration. Works perfectly but they always add as their IEEE address. Some of these devices have up to 10 entities associated, and the moment they are renamed to something sensible, each of those entities 'ceases to exist' in MSR. I like things tidy, and deleting each defunct entity needs 3 clicks. Any chance of a 'bulk delete' option? No biggy as I've pretty much finished my Z-wave migration and I don't expect to be adding more than 2 new Zigbee devices Cheers C
Multi-System Reactor
Reactor (Multi-System/Multi-Hub) Announcements
toggledbitsT
Build 21228 has been released. Docker images available from DockerHub as usual, and bare-metal packages here. Home Assistant up to version 2021.8.6 supported; the online version of the manual will now state the current supported versions; Fix an error in OWMWeatherController that could cause it to stop updating; Unify the approach to entity filtering on all hub interface classes (controllers); this works for device entities only; it may be extended to other entities later; Improve error detail in messages for EzloController during auth phase; Add isRuleSet() and isRuleEnabled() functions to expressions extensions; Implement set action for lock and passage capabilities (makes them more easily scriptable in some cases); Fix a place in the UI where 24-hour time was not being displayed.
Multi-System Reactor
Copying a global reaction
tunnusT
With build 25328, if you copy a global reaction, a new reaction does not appear in the UI unless you do a refresh. I recall this used to work without needing this page refresh? Anyway, only a minor nuisance.
Multi-System Reactor
[Reactor] Bug when sending MQTT boolean payloads
therealdbT
Topic thumbnail image
Multi-System Reactor
Difficulty defining repeating annual period
R
I have tried numerous ways to define a recurring annual period, for example from December 15 to January 15. No matter which method I try - after and before, between, after and/not after, Reactor reports "waiting for invalid date, invalid date. Some constructs also seem to cause Reactor to hang, timeout and restart. For example "before January 15 is evaluated as true, but reports "waiting for invalid date, invalid date". Does anyone have a tried and true method to define a recurring annual period? I think the "between" that I used successfully in the past may have broken with one of the updates.
Multi-System Reactor
Need help with sequence
T
Good evening all, For about the past week or so, I've been having problems with a specific rule in my home automation that controls when my home goes from an Away mode to Home mode. One of the conditions it checked for was my alarm panel, when it changed from Armed Away to Disarmed. There seems to have been a firmware update on the panel that added an intermittent step of "pending", and I can't say for certain it happens 100% of the time. Is there a way to write a condition that so it changes from one condition, to the next, and then another condition? As in, Home alarm changes from armed_away to pending to disarmed. Thanks.
Multi-System Reactor
Possible feature request?
CatmanV2C
No idea how easy this would be. During my migration away from Z-wave I've been replacing the Z-wave devices with Sonoff which has broken some of my automations. Any chance of a 'Test Reaction' function to call out which ones are broken because an entity no longer exists? Without actually running the reaction? Or does this exist already and I'm just not aware of how to do it? Obviously I can see entities that are no longer available, but not quite what I'm looking for. I guess it's something of an edge case so no huge issue. TIA! C
Multi-System Reactor
Logic Assistance: Exterior Lights on when Illuminance Below Threshold
PablaP
Topic thumbnail image
Multi-System Reactor
Time series documentation
tunnusT
Is the current manual (incl. examples) up to date with how retention value is handled in time series configuration? Referring to this post
Multi-System Reactor
MQTT templates for ZIgbee scene controller, or a better way?
CatmanV2C
Topic thumbnail image
Multi-System Reactor
Reset a delay
CatmanV2C
I'm sure this has been asked, and answered, but damned if I can figure it out Use case: I have a rear garden with lights. A door from the kitchen into the garden and a door from the garage. Currently if I open the kitchen door the lights come on (yay) and a 3 minute delay starts. After 3 minutes, no matter what else happens, the lights go off (Boo! But also yay!) What I would like is for the 3 minute delay until the lights go off to start from the latest door open event. That is, if I'm going from kitchen to garage, and back again, the lights stay on until there's three minutes of no activity. I've tried 'hacking' with a virtual switch, but can't seem to stop the delay. Any pointers? TIA C
Multi-System Reactor
Reactor Loading Screen Safari
S
Topic thumbnail image
Multi-System Reactor
Constraints states visually do not match actual
S
Topic thumbnail image
Multi-System Reactor
[MSR] Feature request: For Each action on arrays/groups
therealdbT
Topic thumbnail image
Multi-System Reactor
[Solved] Error: Command timeout
G
at _ClientAPI._commandTimeout (http://192.168.1.100:8111/client/ClientAPI.js:807:179 Seeing this randomly when returning to open browser tab after being away awhile. Once, maybe twice a day. "What did you do to trigger it?" Literally nothing, just walked away and returned and there it was. Actions taken in reasonably close proximity to this particular instance of it popping up: I'd restarted the MSR container in Portainer. I'll try to grab some logs here shortly.
Multi-System Reactor
Issue with MSR UI becoming unresponsive
S
I'm having an issue with MSR's UI being very unresponsive. It started happening a couple days ago and I didn't make any changes that would have caused this except adding some meross lan devices in HA. When I go into an entity action and use the search functionality, it usually will start filtering and then get to a place after a few letters are entered where it will take 30 seconds or more (sometimes minutes) for the UI to show what I am typing. During this time MSR ui is completely unresponsive. I've tried multiple browsers and multiple computers. HA and MSR are both deployed in docker. I have run HTOP on the host and when the problem happens there are no CPU/Memory spikes at all. From a functionality standpoint MSR is working perfectly. This seems to be an UI issue only. Do i need to ditch Docker and run MSR on a Proxmox VM? I have both stand alone Docker and Proxmox environments. I dont mind doing that I just want to be able to use the UI again... Installation method Home Assistant Container Core 2025.7.3 Frontend 20250702.3 nothing crazy in the logs except some openweather map stuff that doesn't make any sense as it is working fine in MSR Any help would be greatly appreciated Reactor latest-25328-b2ed1365 app 25328 configuration from /var/reactor/config NODE_PATH /opt/reactor:/opt/reactor/node_modules [latest-25328]2025-11-30T20:01:53.843Z <app:null> Reactor build latest-25328-b2ed1365 starting on v24.11.1 /usr/local/bin/node [latest-25328]2025-11-30T20:01:53.844Z <app:null> Process ID 1 user/group 0/0; docker; platform linux/x64 #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC 2025; locale (undefined) [latest-25328]2025-11-30T20:01:53.844Z <app:null> Basedir /opt/reactor; data in /var/reactor/storage [latest-25328]2025-11-30T20:01:53.844Z <app:null> NODE_PATH=/opt/reactor:/opt/reactor/node_modules [latest-25328]2025-11-30T20:01:53.865Z <app:null> Resolved timezone=America/New_York, environment TZ=America/New_York; offset minutes from UTC=-300 [latest-25328]2025-11-30T20:01:53.867Z <default:null> Module i18n v25141 [latest-25328]2025-11-30T20:01:53.867Z <app:null> Configured locale (undefined); selected locale(s) en-US.UTF-8 [latest-25328]2025-11-30T20:01:53.879Z <app:null> Loaded locale en-US for en-US [latest-25328]2025-11-30T20:01:53.879Z <app:null> Local date/time using configured timezone and locale formatting is "11/30/2025, 3:01:53 PM" [latest-25328]2025-11-30T20:01:53.889Z <Structure:null> Module Structure v25326 [latest-25328]2025-11-30T20:01:53.890Z <Capabilities:null> Module Capabilities v24312 [latest-25328]2025-11-30T20:01:53.904Z <Plugin:null> Module Plugin v25141 [latest-25328]2025-11-30T20:01:53.923Z <Timer:null> Module Timer v25279 [latest-25328]2025-11-30T20:01:53.924Z <TimerBroker:null> Module TimerBroker v25314 [latest-25328]2025-11-30T20:01:53.927Z <Entity:null> Module Entity v25251 [latest-25328]2025-11-30T20:01:53.929Z <Controller:null> Module Controller v25253 [latest-25328]2025-11-30T20:01:53.930Z <AlertManager:null> Module AlertManager v25318 [latest-25328]2025-11-30T20:01:53.937Z <default:null> Module Ruleset v25283 [latest-25328]2025-11-30T20:01:53.937Z <default:null> Module Rulesets v25141 [latest-25328]2025-11-30T20:01:53.942Z <GlobalExpression:null> Module GlobalExpression v25258 [latest-25328]2025-11-30T20:01:53.953Z <Predicate:null> Module Predicate v25328 [latest-25328]2025-11-30T20:01:53.956Z <Rule:null> Module Rule v25323 [latest-25328]2025-11-30T20:01:53.958Z <GlobalReaction:null> Module GlobalReaction v25292 [latest-25328]2025-11-30T20:01:53.959Z <Engine:null> Module Engine v25325 [latest-25328]2025-11-30T20:01:53.964Z <httpapi:null> Module httpapi v25328 [latest-25328]2025-11-30T20:01:53.972Z <wsapi:null> Module wsapi v25328 [latest-25328]2025-11-30T20:01:53.994Z <TaskQueue:null> Module TaskQueue 24138 [latest-25328]2025-11-30T20:01:53.994Z <VeraController:null> Module VeraController v25141 [latest-25328]2025-11-30T20:01:54.179Z <HassController:null> Module HassController v25325 [latest-25328]2025-11-30T20:02:13.797Z <OWMWeatherController:null> Module OWMWeatherController v25268 [latest-25328]2025-11-30T20:02:13.800Z <SystemController:null> Module SystemController v25323 [latest-25328]2025-11-30T20:02:13.807Z <MQTTController:null> Module MQTTController v22092 [latest-25328]2025-11-30T20:02:20.630Z <OWMWeatherController:CRIT> FetchError: request to https://api.openweathermap.org/data/2.5/weather?lat=xxxxxxxxxx&lon=-xxxxxxxxx&appid=xxxxxxxxxxxxxxxxxxxxxxxxxx&units=standard&_r=1xxxxxxxxxxxxxxfailed, reason: [-] FetchError: request to https://api.openweathermap.org/data/2.5/weather?lat=xxxxxxxxxxx&lon=-xxxxxxxxxxxxxxxxxx&appid=xxxxxxxxxxxxxxxxxxx&units=standard&_r=xxxxxxxxxxxxxxxfailed, reason: at ClientRequest.<anonymous> (/opt/reactor/node_modules/node-fetch/lib/index.js:1501:11) at ClientRequest.emit (node:events:508:28) at ClientRequest.emit (node:domain:489:12) at emitErrorEvent (node:_http_client:108:11) at TLSSocket.socketErrorListener (node:_http_client:575:5) at TLSSocket.emit (node:events:508:28) at TLSSocket.emit (node:domain:489:12) at emitErrorNT (node:internal/streams/destroy:170:8) at emitErrorCloseNT (node:internal/streams/destroy:129:3) at processTicksAndRejections (node:internal/process/task_queues:89:21
Multi-System Reactor
Date/time condition
tunnusT
Topic thumbnail image
Multi-System Reactor

Help updating node.js for bare metal install

Scheduled Pinned Locked Moved Multi-System Reactor
14 Posts 6 Posters 7.5k Views 6 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    gwp1
    wrote on last edited by
    #5

    I had same issue and went back to the MSR manual where it noted if you didn't have a system install of nodejs MSR would do a local one for just it's user.

    I reran the opening steps from the manual and it updated to 18.x just fine.

    *Hubitat C-7 2.4.3.177
    *Proxmox VE v8, Beelink MiniPC 12GBs, SSD

    *HAOS
    Core 2026.1.1
    w/ HA Connect ZWA-2
    FW: v1.1
    SDK: v7.23.1

    *Prod MSR in docker/portainer
    MSR: latest-26011-c621bbc7
    MQTTController: 25139
    ZWave Controller: 25139

    1 Reply Last reply
    0
    • cw-kidC Offline
      cw-kidC Offline
      cw-kid
      wrote on last edited by cw-kid
      #6

      Thanks for the replies and tips.

      In the end after more Googling for my Debian Buster install this seems to have fixed it for me.

      I removed the new /usr/local/bin/node directory that got installed the other day.

      rm /usr/local/bin/node

      Then running the command "which node" the path was back to the old path of /usr/bin/node and "node -v" was showing the old version again of 16.20.2

      I then found these commands on Google and tried them:

      curl -fsSL https://deb.nodesource.com/setup_current.x | sudo -E bash -

      sudo apt-get install -y nodejs

      This seems to have upgraded the 16.20.2 version with a newer version, I saw this line in the terminal output

      Unpacking nodejs (20.5.1-deb-1nodesource1) over (16.20.2-deb-1nodesource1)

      Now when I do a node -v it says its version 20.5.1 and the alert message in MSR has now gone.

      "which node" still says the path is the original path of /usr/bin/node also.

      I have no idea if this was the correct way to do it but I think it has worked.

      1 Reply Last reply
      0
      • wmarcolinW Offline
        wmarcolinW Offline
        wmarcolin
        wrote on last edited by
        #7

        I think we all have a similar problem. My step-by-step was as follows.

        sudo apt remove nodejs
        sudo apt remove npm
        sudo apt autoremove
        
        sudo apt purge nodejs
        sudo apt purge npm
        sudo apt autoremove
        
        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
        
        NODE_MAJOR=20
        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
        
        sudo apt-get update
        sudo apt-get install nodejs -y
        

        Now comes the very rare story, if I'm not as toot I get this information.

        node -v
        v20.10.0
        
        npm -v
        10.2.3
        
        

        PERFECT!!

        But after the su --, I become root and the version that comes is 12? and then I really don't understand. I did the tasks like this, as root and without root, in the same way.

        If any expert can help me understand this madness.

        Thanks.

        1 Reply Last reply
        0
        • toggledbitsT Offline
          toggledbitsT Offline
          toggledbits
          wrote on last edited by
          #8

          The PATH environment variable for root is different from that of regular users. You can echo $PATH in each to see the differences. The path is processed in order, first come first served.

          Author of Multi-system Reactor and Reactor, DelayLight, Switchboard, and about a dozen other plugins that run on Vera and openLuup.

          1 Reply Last reply
          1
          • wmarcolinW Offline
            wmarcolinW Offline
            wmarcolin
            wrote on last edited by
            #9

            Well, I've just solved my problem, whether it's the right way or not I can't say, but it was brute force, I used the "which node" command, I located all the directories regardless of version and deleted them (rm node -r), this while being root. Then I did a fresh install 🙂 solved.

            toggledbitsT 1 Reply Last reply
            0
            • wmarcolinW wmarcolin

              Well, I've just solved my problem, whether it's the right way or not I can't say, but it was brute force, I used the "which node" command, I located all the directories regardless of version and deleted them (rm node -r), this while being root. Then I did a fresh install 🙂 solved.

              toggledbitsT Offline
              toggledbitsT Offline
              toggledbits
              wrote on last edited by toggledbits
              #10

              @wmarcolin That may have worked, but it's not strictly right and may lead to complications down the road, like versions of node and npm being out of sync.

              NOTE: Some of this can be used as instructions. Read all carefully and understand what you are doing before you actually do anything. If you don't understand, ask first, understand first, then proceed (always with caution and careful attention to detail).

              Generally speaking, it's not a good idea to tamper with the system-installed version of any utility if there is one. If you use a command like apt-get install node or similar and it puts a version into /usr/bin, that's where you should leave it, and never change it (unless apt or yum does). That's because the system packages are versioned together as a group, so other system utilities may have dependencies on that system-blessed version of the package and its associated utilities and libraries.

              When you want a newer version of node, the generally-recommended way is to do a custom install, which can be done either to a user-specific directory (so that one user can have a private version), or system-wide in a location under /usr/local (usually installed in /usr/local/lib with symbolic links from /usr/local/bin for the executables).

              Either way, the version of node that runs is the first one encountered in the PATH environment then in effect.

              Reactor has been tested with all three common install methods: the native system packages, when up to date; a /usr/local install; and a user-directory-specific install. All work fine.

              Taking the structure of one of my RPis running Raspbian Buster (Debian 10), but should apply to almost any Linux-based platform...

              The default system install puts a node and npm in /usr/bin:

              pi@rpi4-2:~ $ ls -l /usr/bin/node
              -rwxr-xr-x 1 root root 5536 Feb 24  2023 /usr/bin/node
              pi@rpi4-2:~ $ /usr/bin/node -v
              v10.24.0
              pi@rpi4-2:~ $
              

              Notice that when I ran the node command, I ran it with a full path (i.e. as /usr/bin/node and not just typing node). That's because I have a newer version of node installed in /usr/local that is configured to take precedence. And also notice how old that system-installed package is!

              My later-version installation in /usr/local/lib (specifically) looks like this:

              pi@rpi4-2:~ $ ls -l /usr/local/lib/
              total 12
              drwxr-xr-x 3 root root  4096 Nov 26 08:59 nodejs
              drwxrwsr-x 4 root staff 4096 Nov 26 09:13 python2.7
              drwxrwsr-x 3 root staff 4096 May  7  2021 python3.7
              pi@rpi4-2:~ $ ls -l /usr/local/lib/nodejs
              total 42112
              drwxr-xr-x 6 1001 1001     4096 Oct 13 10:03 node-v18.18.2-linux-armv7l
              -rw-r--r-- 1 root root 20932900 Oct 13 10:05 node-v18.18.2-linux-armv7l.tar.xz
              -rw-r--r-- 1 root root 22182716 Nov 22 07:30 node-v20.10.0-linux-armv7l.tar.xz
              pi@rpi4-2:~ $
              

              You can see here, I have a nodejs subdirectory in /usr/local/lib. In here, I've got the downloaded archives for two versions (an 18 and a 20), of which the 18 is currently unpacked in the directory node-v18.18.2-linux-armv7l. That's a completely self-contained package for nodejs, ready to run. All that was needed was to configure it to run.

              Configuring this version of node to run took two additional steps. First, I went to /usr/local/bin, and symbolically linked the executables from the v18 package, like this (notice I'm doing this step as root) :

              root@rpi4-2:~# cd /usr/local/bin
              root@rpi4-2:/usr/local/bin# ln -sf /usr/local/lib/nodejs/node-v18.18.2-linux-armv7l/bin/* .
              root@rpi4-2:/usr/local/bin# ls -l
              total 4
              lrwxrwxrwx 1 root root 61 Dec 11 12:30 corepack -> /usr/local/lib/nodejs/node-v18.18.2-linux-armv7l/bin/corepack
              lrwxrwxrwx 1 root root 57 Dec 11 12:30 node -> /usr/local/lib/nodejs/node-v18.18.2-linux-armv7l/bin/node
              lrwxrwxrwx 1 root root 56 Dec 11 12:30 npm -> /usr/local/lib/nodejs/node-v18.18.2-linux-armv7l/bin/npm
              lrwxrwxrwx 1 root root 56 Dec 11 12:30 npx -> /usr/local/lib/nodejs/node-v18.18.2-linux-armv7l/bin/npx
              root@rpi4-2:/usr/local/bin#
              

              The first command changes directory to /usr/local/bin, and the second symbolically links all files in the package's bin subdirectory to the current directory (which is our /usr/local/bin). The ls command shows the result of that operation. So you can see, the executable in /usr/local/bin/node isn't an executable at all, it's a symbolic link to the executable in the package directory. Same with the other nodejs commands in the package.

              The last step is to get that executable in /usr/local/bin/node to take precedence over the older version in the system install (i.e. the one in /usr/bin/node). All that is required to do this is that /usr/local/bin/node be seen by the shell before /usr/bin/node. This is done by making sure /usr/local/bin comes before /usr/bin in the PATH environment variable. On most systems, this is already the default case -- it's set up that way and you don't need to do anything. On some systems, you may need to add it. This can be done by adding a snippet like the following to the end of /etc/profile (to make it a system-wide change):

              PATH=/usr/local/bin:$PATH
              export PATH
              

              This puts /usr/local/bin at the head of the PATH. Again, this usually isn't necessary, because /usr/local/bin is already early in the path on most systems by default. You can check your path by doing echo $PATH as I said before. If you do end up having to make this change, you'll need to log out and log back in to make it take effect. And, any time you edit anything in /etc, it's a good idea to make a backup copy of the unmodified file first, in case you goof something up and need to revert (cp /etc/profile /etc/profile.old is sufficient).

              If you're installing a per-user version of nodejs, the structure is fairly similar, but rather than unpacking the nodejs archive into /usr/local/lib/nodejs, you unpack it into ~/.local/lib/nodejs/ (remember ~ is a synonym for $HOME and means the current user's home directory path) with the same structure that I showed above for /usr/local/.... Notice we are not root here!

              # For user-local install, all work is done NOT as root. Here, I'm just "pi"
              pi@rpi4-2:~ $ mkdir -p ~/.local/lib
              pi@rpi4-2:~ $ mkdir -p ~/.local/bin
              pi@rpi4-2:~ $ cd ~/.local/lib/
              pi@rpi4-2:~/.local/lib $ mkdir -p nodejs
              pi@rpi4-2:~/.local/lib $ cd nodejs
              pi@rpi4-2:~/.local/lib/nodejs $ wget 'https://nodejs.org/dist/latest-v20.x/node-v20.10.0-linux-armv7l.tar.xz'
              --2023-12-11 12:46:55--  https://nodejs.org/dist/latest-v20.x/node-v20.10.0-linux-armv7l.tar.xz
              Resolving nodejs.org (nodejs.org)... 104.20.23.46, 104.20.22.46, 2606:4700:10::6814:162e, ...
              Connecting to nodejs.org (nodejs.org)|104.20.23.46|:443... connected.
              HTTP request sent, awaiting response... 200 OK
              Length: 22182716 (21M) [application/x-xz]
              Saving to: ânode-v20.10.0-linux-armv7l.tar.xz.1â
              
              node-v20.10.0-linux-armv7l.tar.x 100%[==========================================================>]  21.15M  18.5MB/s    in 1.1s
              
              2023-12-11 12:46:57 (18.5 MB/s) - ânode-v20.10.0-linux-armv7l.tar.xz.1â saved [22182716/22182716]
              
              pi@rpi4-2:~/.local/lib/nodejs $ ls
              node-v20.10.0-linux-armv7l.tar.xz
              pi@rpi4-2:~/.local/lib/nodejs $ tar xJf node-v20.10.0-linux-armv7l.tar.xz    # J is for .xz, z is for .gz
              pi@rpi4-2:~/.local/lib/nodejs $ cd ~/.local/bin
              pi@rpi4-2:~/.local/bin $ ln -sf ~/.local/lib/nodejs/node-v20.10.0-linux-armv7l/bin/* .
              pi@rpi4-2:~/.local/bin $ ls -l
              total 16
              lrwxrwxrwx 1 pi pi 66 Dec 11 12:48 corepack -> /home/pi/.local/lib/nodejs/node-v20.10.0-linux-armv7l/bin/corepack
              lrwxrwxrwx 1 pi pi 62 Dec 11 12:48 node -> /home/pi/.local/lib/nodejs/node-v20.10.0-linux-armv7l/bin/node
              lrwxrwxrwx 1 pi pi 61 Dec 11 12:48 npm -> /home/pi/.local/lib/nodejs/node-v20.10.0-linux-armv7l/bin/npm
              lrwxrwxrwx 1 pi pi 61 Dec 11 12:48 npx -> /home/pi/.local/lib/nodejs/node-v20.10.0-linux-armv7l/bin/npx
              pi@rpi4-2:~/.local/bin $
              

              Reading these steps, the first five commands create the structure of the .local subdirectory needed, with subdirectories bin, lib and lib/nodejs within just like we would have in /usr/local. At this point, the current directory is ~/.local/lib/nodejs, and the wget command is used to download the nodejs package we want (change version and architecture to what you need if you are actually doing this). Then we un-tar it right where we are. After un-taring it, we change directory to our own ~/.local/bin and make the symbolic links for the nodejs commands in the package directory, just like we did for /usr/local.

              The last step is again, and this may be default, is making sure this user's PATH environment variable includes our new local ~/.local/bin directory. Check it with echo $PATH to see if you need to make the addition. If so, the easiest way to do that is to add the following snipped to ~/.profile, which is the per-user equivalent to /etc/profile (the per-user script runs after the /etc script at login) to set up the shell environment. My Raspbian Buster (Debian 10) systems seem to have this done already as a default, so before making any changes, check your PATH and/or ~/.profile.

              PATH=$HOME/.local/bin:$PATH
              export PATH
              

              Log out and back in, and then a which node should give you ~/.local/bin/node (or /home/username/.local/bin/node). You then have a per-user custom version of nodejs that doesn't interfere with any system versions.

              Now, for running Reactor as a service, you need to be aware of where you are running it, and as who. It's generally not recommended to run Reactor as root on any bare-metal system (it runs as root on docker containers, but that's OK because the container is a constrained virtual environment). So when setting up, for example, your systemd profile for Reactor, you would want to make sure the profile contains both a User directory to set the correct (non-root) user for the running process, and a full path to the correct node executable in ExecStart (e.g. ExecStart=/home/pi/.local/bin/node app -p).

              One last point: nodejs is so well-written that its entire dependencies exist entirely within its package structure, so whatever node command runs knows automatically where to find everything else it needs — you don't need to set a bunch of other environment variables to make each version work properly. That means you could, for example, run /usr/bin/node and see a perfectly working v10.24.0 as I showed above, or /usr/local/bin/node and get a perfectly-working v18.18.2 if that's what is installed there, and ~/.local/bin/node to get a fine v20.9.0 environment if that's what's installed there. Not all packages are this tight, and we can be grateful for it.

              Tip: don't stop at which node when you are trying to figure out what is running. nodejs itself makes extensive use of symbolic links, so doing which node is only the tip of the iceberg. You need to then do ls -l /that-path and see if it's a symbolic link to somewhere else, as I showed in the output above. Keep following those links until you find the "real deal" and you'll find which version is actually running and where it actually lives.

              I hope some of this clarifies how nodejs is installed, and highlights how you can actually have multiple versions of it installed on the system and they co-exist quite well, you just have to be careful.

              Author of Multi-system Reactor and Reactor, DelayLight, Switchboard, and about a dozen other plugins that run on Vera and openLuup.

              wmarcolinW 1 Reply Last reply
              3
              • CatmanV2C Offline
                CatmanV2C Offline
                CatmanV2
                wrote on last edited by
                #11

                @toggledbits fabulous post, there. Thanks. 18.19.0 in /usr/local/bin for Reactor and, apparently working fine 🙂

                Any particular reason not to go to 21?

                Cheers

                C

                The Ex-Vera abuser know as CatmanV2.....

                toggledbitsT 1 Reply Last reply
                0
                • CatmanV2C CatmanV2

                  @toggledbits fabulous post, there. Thanks. 18.19.0 in /usr/local/bin for Reactor and, apparently working fine 🙂

                  Any particular reason not to go to 21?

                  Cheers

                  C

                  toggledbitsT Offline
                  toggledbitsT Offline
                  toggledbits
                  wrote on last edited by toggledbits
                  #12

                  @CatmanV2 said in Help updating node.js for bare metal install:

                  Any particular reason not to go to 21?

                  Yes! Only even-numbered versions of nodejs are LTS (long-term support). For the longest life of the system between upgrades like this, use the LTS versions only. That's why I recommend 18 and 20.

                  Here's their release and support calendar: https://nodejs.github.io/nodejs.dev/en/about/releases/

                  Notice that 21 will be EOL far sooner than either 18 or 20.

                  Author of Multi-system Reactor and Reactor, DelayLight, Switchboard, and about a dozen other plugins that run on Vera and openLuup.

                  1 Reply Last reply
                  1
                  • CatmanV2C Offline
                    CatmanV2C Offline
                    CatmanV2
                    wrote on last edited by
                    #13

                    Doh! Thanks for that!

                    C

                    The Ex-Vera abuser know as CatmanV2.....

                    1 Reply Last reply
                    0
                    • toggledbitsT toggledbits

                      @wmarcolin That may have worked, but it's not strictly right and may lead to complications down the road, like versions of node and npm being out of sync.

                      NOTE: Some of this can be used as instructions. Read all carefully and understand what you are doing before you actually do anything. If you don't understand, ask first, understand first, then proceed (always with caution and careful attention to detail).

                      Generally speaking, it's not a good idea to tamper with the system-installed version of any utility if there is one. If you use a command like apt-get install node or similar and it puts a version into /usr/bin, that's where you should leave it, and never change it (unless apt or yum does). That's because the system packages are versioned together as a group, so other system utilities may have dependencies on that system-blessed version of the package and its associated utilities and libraries.

                      When you want a newer version of node, the generally-recommended way is to do a custom install, which can be done either to a user-specific directory (so that one user can have a private version), or system-wide in a location under /usr/local (usually installed in /usr/local/lib with symbolic links from /usr/local/bin for the executables).

                      Either way, the version of node that runs is the first one encountered in the PATH environment then in effect.

                      Reactor has been tested with all three common install methods: the native system packages, when up to date; a /usr/local install; and a user-directory-specific install. All work fine.

                      Taking the structure of one of my RPis running Raspbian Buster (Debian 10), but should apply to almost any Linux-based platform...

                      The default system install puts a node and npm in /usr/bin:

                      pi@rpi4-2:~ $ ls -l /usr/bin/node
                      -rwxr-xr-x 1 root root 5536 Feb 24  2023 /usr/bin/node
                      pi@rpi4-2:~ $ /usr/bin/node -v
                      v10.24.0
                      pi@rpi4-2:~ $
                      

                      Notice that when I ran the node command, I ran it with a full path (i.e. as /usr/bin/node and not just typing node). That's because I have a newer version of node installed in /usr/local that is configured to take precedence. And also notice how old that system-installed package is!

                      My later-version installation in /usr/local/lib (specifically) looks like this:

                      pi@rpi4-2:~ $ ls -l /usr/local/lib/
                      total 12
                      drwxr-xr-x 3 root root  4096 Nov 26 08:59 nodejs
                      drwxrwsr-x 4 root staff 4096 Nov 26 09:13 python2.7
                      drwxrwsr-x 3 root staff 4096 May  7  2021 python3.7
                      pi@rpi4-2:~ $ ls -l /usr/local/lib/nodejs
                      total 42112
                      drwxr-xr-x 6 1001 1001     4096 Oct 13 10:03 node-v18.18.2-linux-armv7l
                      -rw-r--r-- 1 root root 20932900 Oct 13 10:05 node-v18.18.2-linux-armv7l.tar.xz
                      -rw-r--r-- 1 root root 22182716 Nov 22 07:30 node-v20.10.0-linux-armv7l.tar.xz
                      pi@rpi4-2:~ $
                      

                      You can see here, I have a nodejs subdirectory in /usr/local/lib. In here, I've got the downloaded archives for two versions (an 18 and a 20), of which the 18 is currently unpacked in the directory node-v18.18.2-linux-armv7l. That's a completely self-contained package for nodejs, ready to run. All that was needed was to configure it to run.

                      Configuring this version of node to run took two additional steps. First, I went to /usr/local/bin, and symbolically linked the executables from the v18 package, like this (notice I'm doing this step as root) :

                      root@rpi4-2:~# cd /usr/local/bin
                      root@rpi4-2:/usr/local/bin# ln -sf /usr/local/lib/nodejs/node-v18.18.2-linux-armv7l/bin/* .
                      root@rpi4-2:/usr/local/bin# ls -l
                      total 4
                      lrwxrwxrwx 1 root root 61 Dec 11 12:30 corepack -> /usr/local/lib/nodejs/node-v18.18.2-linux-armv7l/bin/corepack
                      lrwxrwxrwx 1 root root 57 Dec 11 12:30 node -> /usr/local/lib/nodejs/node-v18.18.2-linux-armv7l/bin/node
                      lrwxrwxrwx 1 root root 56 Dec 11 12:30 npm -> /usr/local/lib/nodejs/node-v18.18.2-linux-armv7l/bin/npm
                      lrwxrwxrwx 1 root root 56 Dec 11 12:30 npx -> /usr/local/lib/nodejs/node-v18.18.2-linux-armv7l/bin/npx
                      root@rpi4-2:/usr/local/bin#
                      

                      The first command changes directory to /usr/local/bin, and the second symbolically links all files in the package's bin subdirectory to the current directory (which is our /usr/local/bin). The ls command shows the result of that operation. So you can see, the executable in /usr/local/bin/node isn't an executable at all, it's a symbolic link to the executable in the package directory. Same with the other nodejs commands in the package.

                      The last step is to get that executable in /usr/local/bin/node to take precedence over the older version in the system install (i.e. the one in /usr/bin/node). All that is required to do this is that /usr/local/bin/node be seen by the shell before /usr/bin/node. This is done by making sure /usr/local/bin comes before /usr/bin in the PATH environment variable. On most systems, this is already the default case -- it's set up that way and you don't need to do anything. On some systems, you may need to add it. This can be done by adding a snippet like the following to the end of /etc/profile (to make it a system-wide change):

                      PATH=/usr/local/bin:$PATH
                      export PATH
                      

                      This puts /usr/local/bin at the head of the PATH. Again, this usually isn't necessary, because /usr/local/bin is already early in the path on most systems by default. You can check your path by doing echo $PATH as I said before. If you do end up having to make this change, you'll need to log out and log back in to make it take effect. And, any time you edit anything in /etc, it's a good idea to make a backup copy of the unmodified file first, in case you goof something up and need to revert (cp /etc/profile /etc/profile.old is sufficient).

                      If you're installing a per-user version of nodejs, the structure is fairly similar, but rather than unpacking the nodejs archive into /usr/local/lib/nodejs, you unpack it into ~/.local/lib/nodejs/ (remember ~ is a synonym for $HOME and means the current user's home directory path) with the same structure that I showed above for /usr/local/.... Notice we are not root here!

                      # For user-local install, all work is done NOT as root. Here, I'm just "pi"
                      pi@rpi4-2:~ $ mkdir -p ~/.local/lib
                      pi@rpi4-2:~ $ mkdir -p ~/.local/bin
                      pi@rpi4-2:~ $ cd ~/.local/lib/
                      pi@rpi4-2:~/.local/lib $ mkdir -p nodejs
                      pi@rpi4-2:~/.local/lib $ cd nodejs
                      pi@rpi4-2:~/.local/lib/nodejs $ wget 'https://nodejs.org/dist/latest-v20.x/node-v20.10.0-linux-armv7l.tar.xz'
                      --2023-12-11 12:46:55--  https://nodejs.org/dist/latest-v20.x/node-v20.10.0-linux-armv7l.tar.xz
                      Resolving nodejs.org (nodejs.org)... 104.20.23.46, 104.20.22.46, 2606:4700:10::6814:162e, ...
                      Connecting to nodejs.org (nodejs.org)|104.20.23.46|:443... connected.
                      HTTP request sent, awaiting response... 200 OK
                      Length: 22182716 (21M) [application/x-xz]
                      Saving to: ânode-v20.10.0-linux-armv7l.tar.xz.1â
                      
                      node-v20.10.0-linux-armv7l.tar.x 100%[==========================================================>]  21.15M  18.5MB/s    in 1.1s
                      
                      2023-12-11 12:46:57 (18.5 MB/s) - ânode-v20.10.0-linux-armv7l.tar.xz.1â saved [22182716/22182716]
                      
                      pi@rpi4-2:~/.local/lib/nodejs $ ls
                      node-v20.10.0-linux-armv7l.tar.xz
                      pi@rpi4-2:~/.local/lib/nodejs $ tar xJf node-v20.10.0-linux-armv7l.tar.xz    # J is for .xz, z is for .gz
                      pi@rpi4-2:~/.local/lib/nodejs $ cd ~/.local/bin
                      pi@rpi4-2:~/.local/bin $ ln -sf ~/.local/lib/nodejs/node-v20.10.0-linux-armv7l/bin/* .
                      pi@rpi4-2:~/.local/bin $ ls -l
                      total 16
                      lrwxrwxrwx 1 pi pi 66 Dec 11 12:48 corepack -> /home/pi/.local/lib/nodejs/node-v20.10.0-linux-armv7l/bin/corepack
                      lrwxrwxrwx 1 pi pi 62 Dec 11 12:48 node -> /home/pi/.local/lib/nodejs/node-v20.10.0-linux-armv7l/bin/node
                      lrwxrwxrwx 1 pi pi 61 Dec 11 12:48 npm -> /home/pi/.local/lib/nodejs/node-v20.10.0-linux-armv7l/bin/npm
                      lrwxrwxrwx 1 pi pi 61 Dec 11 12:48 npx -> /home/pi/.local/lib/nodejs/node-v20.10.0-linux-armv7l/bin/npx
                      pi@rpi4-2:~/.local/bin $
                      

                      Reading these steps, the first five commands create the structure of the .local subdirectory needed, with subdirectories bin, lib and lib/nodejs within just like we would have in /usr/local. At this point, the current directory is ~/.local/lib/nodejs, and the wget command is used to download the nodejs package we want (change version and architecture to what you need if you are actually doing this). Then we un-tar it right where we are. After un-taring it, we change directory to our own ~/.local/bin and make the symbolic links for the nodejs commands in the package directory, just like we did for /usr/local.

                      The last step is again, and this may be default, is making sure this user's PATH environment variable includes our new local ~/.local/bin directory. Check it with echo $PATH to see if you need to make the addition. If so, the easiest way to do that is to add the following snipped to ~/.profile, which is the per-user equivalent to /etc/profile (the per-user script runs after the /etc script at login) to set up the shell environment. My Raspbian Buster (Debian 10) systems seem to have this done already as a default, so before making any changes, check your PATH and/or ~/.profile.

                      PATH=$HOME/.local/bin:$PATH
                      export PATH
                      

                      Log out and back in, and then a which node should give you ~/.local/bin/node (or /home/username/.local/bin/node). You then have a per-user custom version of nodejs that doesn't interfere with any system versions.

                      Now, for running Reactor as a service, you need to be aware of where you are running it, and as who. It's generally not recommended to run Reactor as root on any bare-metal system (it runs as root on docker containers, but that's OK because the container is a constrained virtual environment). So when setting up, for example, your systemd profile for Reactor, you would want to make sure the profile contains both a User directory to set the correct (non-root) user for the running process, and a full path to the correct node executable in ExecStart (e.g. ExecStart=/home/pi/.local/bin/node app -p).

                      One last point: nodejs is so well-written that its entire dependencies exist entirely within its package structure, so whatever node command runs knows automatically where to find everything else it needs — you don't need to set a bunch of other environment variables to make each version work properly. That means you could, for example, run /usr/bin/node and see a perfectly working v10.24.0 as I showed above, or /usr/local/bin/node and get a perfectly-working v18.18.2 if that's what is installed there, and ~/.local/bin/node to get a fine v20.9.0 environment if that's what's installed there. Not all packages are this tight, and we can be grateful for it.

                      Tip: don't stop at which node when you are trying to figure out what is running. nodejs itself makes extensive use of symbolic links, so doing which node is only the tip of the iceberg. You need to then do ls -l /that-path and see if it's a symbolic link to somewhere else, as I showed in the output above. Keep following those links until you find the "real deal" and you'll find which version is actually running and where it actually lives.

                      I hope some of this clarifies how nodejs is installed, and highlights how you can actually have multiple versions of it installed on the system and they co-exist quite well, you just have to be careful.

                      wmarcolinW Offline
                      wmarcolinW Offline
                      wmarcolin
                      wrote on last edited by
                      #14

                      @toggledbits

                      Super thanks for the master class!!!!

                      1 Reply Last reply
                      1
                      • toggledbitsT toggledbits locked this topic on
                      Reply
                      • Reply as topic
                      Log in to reply
                      • Oldest to Newest
                      • Newest to Oldest
                      • Most Votes


                      Recent Topics

                      • Oddness in Copy/Move of Reactions
                        G
                        gwp1
                        0
                        1
                        32

                      • [Solved] function isRuleEnabled() issue
                        CrilleC
                        Crille
                        0
                        4
                        49

                      • [Reactor] Problem with Global Reactions and groups
                        therealdbT
                        therealdb
                        0
                        3
                        69

                      • Possible feature request 2?
                        CatmanV2C
                        CatmanV2
                        0
                        3
                        50

                      • Reactor (Multi-System/Multi-Hub) Announcements
                        toggledbitsT
                        toggledbits
                        5
                        133
                        79.6k

                      • Genuinely impressed with Zigbee and HA / Reactor
                        CatmanV2C
                        CatmanV2
                        1
                        9
                        347

                      • Copying a global reaction
                        toggledbitsT
                        toggledbits
                        0
                        3
                        95

                      • [HowTo] Using HABridge with Reactor
                        CatmanV2C
                        CatmanV2
                        0
                        9
                        417

                      • [Reactor] Bug when sending MQTT boolean payloads
                        toggledbitsT
                        toggledbits
                        0
                        4
                        154

                      • Difficulty defining repeating annual period
                        G
                        gwp1
                        0
                        5
                        123

                      • Need help with sequence
                        therealdbT
                        therealdb
                        0
                        3
                        76

                      • Possible feature request?
                        therealdbT
                        therealdb
                        0
                        5
                        185
                      Powered by NodeBB | Contributors
                      Hosted freely by 10RUPTiV - Solutions Technologiques | Contact us
                      • Login

                      • Don't have an account? Register

                      • Login or register to search.
                      • First post
                        Last post
                      0
                      • Categories
                      • Recent
                      • Tags
                      • Popular
                      • Unsolved