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
Gradually turn on lights.
Tom_DT
I have several lights that I would like to turn on very gradually over 15 or 20 seconds. from 0 to .25 in .01 increments. I have tried a few things that came nowhere near working, so here I am.
Multi-System Reactor
Error After Upgrade
T
Topic thumbnail image
Multi-System Reactor
Reset attribute value of entity in event handler
R
Topic thumbnail image
Multi-System Reactor
Need help figuring out how to delay a reset on reaction
T
Topic thumbnail image
Multi-System Reactor
Way to search for rules (rule state) in other rules
T
@toggledbits, not sure if this is a feature request or I'm using the search tool wrong. You have a "Search for rule" in the Rules Set tab in MSR. It works nicely to find a rule and bring up said rule, but can it/could it be used for as a "where used?" global search? For instance, I have a fairly large set of rules, divided up into 10 different rulesets. There's easily a hundred individual rules, and many of the rules have Rule State triggers, which of course refer to other rules. Amongst my troubleshooting today, I came across what may have been a duplicate or troubleshooting attempt, but I can't tell if it's actually used as a Rule State in another rule without opening each rule that I suspect it may be a part of. Thanks.
Multi-System Reactor
Links to MSR from HA
Tom_DT
I am using Home Assistant a lot recently. On a dashboard showing the devices, I would like to show a link to the MSR rule that controls the devices. Is there a way to link directly into MSR?
Multi-System Reactor
Set Reaction > Script Action
wmarcolinW
Topic thumbnail image
Multi-System Reactor
Errors after updating to MQTTController build 25139
tunnusT
I'm running MSR build 25139 on Docker, using MQTT controller 24293, and everything working as expected. But if I try to upgrade to MQTTController build 25139, I'm getting the following errors on MSR UI: An Entity Attribute condition in "Lay-Z-Spa auto heating off" (Terrace) failed because the referenced entity "Lay-Z-Spa States" (mqtt>layzspa_states) does not have attribute value_sensor.god Last 11:20:37 An Entity Attribute condition in "Lay-Z-Spa auto heating off" (Terrace) failed because the referenced entity "Lay-Z-Spa States" (mqtt>layzspa_states) does not have attribute temperature_sensor.green Last 11:20:37 An Entity Attribute condition in "Lay-Z-Spa filter pump auto off" (Terrace) failed because the referenced entity "Lay-Z-Spa States" (mqtt>layzspa_states) does not have attribute temperature_sensor.red Last 11:20:37 An Entity Attribute condition in "Lay-Z-Spa filter pump auto run" (Terrace) failed because the referenced entity "Lay-Z-Spa States" (mqtt>layzspa_states) does not have attribute value_sensor.pump Last 11:20:37 An Entity Attribute condition in "Lay-Z-Spa watchdog" (Terrace) failed because the referenced entity "Lay-Z-Spa States" (mqtt>layzspa_states) does not have attribute value_sensor.status Last 11:20:37 My MQTT configuration (local_mqtt_devices.yaml) for the related entity is: layzspa_message: type: ValueSensor capabilities: ["temperature_sensor", "value_sensor", "power_sensor"] primary_attribute: power_sensor.value events: "layzspa/message": "power_sensor.value": json_payload: true if_expr: '! isnull( payload?.PWR )' expr: "float(payload.PWR)" "value_sensor.air": json_payload: true if_expr: '! isnull( payload?.AIR )' expr: "float(payload.AIR)" "value_sensor.pump": json_payload: true if_expr: '! isnull( payload?.FLT )' expr: "float(payload.FLT)" "value_sensor.god": json_payload: true if_expr: '! isnull( payload?.GOD )' expr: "float(payload.GOD)" "value_sensor.lock": json_payload: true if_expr: '! isnull( payload?.LCK )' expr: "float(payload.LCK)" "value_sensor.unit": json_payload: true if_expr: '! isnull( payload?.UNT )' expr: "float(payload.UNT)" "value_sensor.error": json_payload: true if_expr: '! isnull( payload?.ERR )' expr: "float(payload.ERR)" "temperature_sensor.green": json_payload: true if_expr: '! isnull( payload?.GRN )' expr: "float(payload.GRN)" "temperature_sensor.red": json_payload: true if_expr: '! isnull( payload?.RED )' expr: "float(payload.RED)" "temperature_sensor.target": json_payload: true if_expr: '! isnull( payload?.TGT )' expr: "float(payload.TGT)" "temperature_sensor.value": json_payload: true if_expr: '! isnull( payload?.TMP )' expr: "float(payload.TMP)" "temperature_sensor.virtual": json_payload: true if_expr: '! isnull( payload?.VTM )' expr: "round(float(payload.VTM), 1)" "temperature_sensor.ambient": json_payload: true if_expr: '! isnull( payload?.AMB )' expr: "float(payload.AMB)" "layzspa/Status": "value_sensor.status": if_expr: '! isnull( payload )' expr: "payload" "layzspa/button": "value_sensor.button": if_expr: '! isnull( payload )' expr: "payload" and in reactor.yaml I have: "layzspa_states": name: "Lay-Z-Spa States" friendly_name: 'Lay-Z-Spa States' include: layzspa_message I realize my MQTT configuration might be a bit unorthodox, but could there still be something unintentional in the latest MQTTController build? If needed, I can provide detailed logs.
Multi-System Reactor
🎉 My very first MSR controller: OpenSprinkler
therealdbT
Since today is my birthday - and I still pretend to be unconventional - I'm giving away a present to this wonderful community and I'm releasing my first OpenSprinkler controller for MSR. It was real fun to code it - and while it's still WIP, it seems to work OK for me. It's polling-based at the moment, but I'll add support for updates via MQTT very soon (it's already partially coded). Get it at (install is similar to MQTTController and such): https://github.com/dbochicchio/reactor-opensprinkler Feel free to try it. It's beta software, but it's stable. I'll update it weekly until all the tasks from my todo list are empty. Since I've learnt a lot from this controller, I'll explore new controllers soon.
Multi-System Reactor
Advice reqeusted to migrate MSR from Bare Metal to Container
T
Good day all, I'm in the process of trying to shut down my 10 year old Linux home server that served many purposes, but primarily it's what I used for my NAS/Plex Media server. I migrated the NAS aspect of the server in November of last year to a true NAS solution (Ubiquti UNAS Pro), which is rack mount and much more efficient than my old tower, which it's only side benefit was heating my home office during the winter. Unfortunately it also means heating my home office during the summer, which were about to be in full swing. I have two things running on this 10 year old server at this point. MSR and pi-hole. I'm running Plex Media Server on Fedora Workstation in Podman on mini PC, which is much more energy efficient than my old tower. My next step is to migrate MSR. I know there are images of MSR out there, and creating it is well documented. I'm going to be using Podman instead of Docker for various reasons, but they work very similar. What I don't know, is what I need to do to migrate my existing Bare Metal installation over to a container. Has anyone done this? Any advice?
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
Can´t restart or upgrade/deploy MSR
F
Topic thumbnail image
Multi-System Reactor
[Solved] Limit HA Entity in MSR
wmarcolinW
Topic thumbnail image
Multi-System Reactor
Organizing/ structuring rule sets and rules
R
Hi guys, Just wondering how you guys organize your rule sets and rules. I wish I had an extra layer to have some more granularity, but my feature request was not popular. Maybe there are better ways to organize my rule sets. I use the rule sets now primarily for rooms. So a rule set per room. But maybe grouping by functionality works better. Any examples/ suggestions would be appreciated.
Multi-System Reactor
Moving MSR from a QNAP container to RP 5 - some issues
Tom_DT
Topic thumbnail image
Multi-System Reactor
Widget deletion does not work and landing page (status) is empy
M
Topic thumbnail image
Multi-System Reactor
Need help reducing false positive notifications
T
Topic thumbnail image
Multi-System Reactor
Deleting widgets
tunnusT
Hopefully a trivial question, but how do you delete widgets in a status page? Using build 22266
Multi-System Reactor
MQTT configuration question
tunnusT
I have the following yaml configuration in local_mqtt_devices file x_mqtt_device: set_speed: arguments: speed: type: str topic: "command/%friendly_name%" payload: type: json expr: '{ "fan": parameters.speed }' While this works fine, I'm wondering how this could be changed to "fixed" parameters, as in this case "fan" only accepts "A", "Q" or a numeric value of 1-5?
Multi-System Reactor
System Configuration Check - time is offset
F
Hi! I get this message when I'm on the status tab: System Configuration Check The time on this system and on the Reactor host are significantly different. This may be due to incorrect system configuration on either or both. Please check the configuration of both systems. The host reports 2025-04-01T15:29:29.252Z; browser reports 2025-04-01T15:29:40.528Z; difference 11.276 seconds. I have MSR installed as a docker on my Home Assistant Blue / Hardkernel ODROID-N2/N2+. MSR version is latest-25082-3c348de6. HA versions are: Core 2025.3.4 Supervisor 2025.03.4 Operating System 15.1 I have restarted HA as well as MSR multiple times. This message didn´t show two weeks ago. Don´t know if it have anything to do with the latest MSR version. Do anyone know what I can try? Thanks in advance! Let's Be Careful Out There (Hill Street reference...) /Fanan
Multi-System Reactor

Help updating node.js for bare metal install

Scheduled Pinned Locked Moved Multi-System Reactor
14 Posts 6 Posters 6.4k 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.1.177
    *Proxmox VE v8, Beelink MiniPC 12GBs, SSD

    *HASS 2025.6.0
    w/ ZST10-700 fw 7.18.3

    *Prod MSR in docker/portainer
    MSR: latest-25139-fbd67abc
    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

                      • Gradually turn on lights.
                        toggledbitsT
                        toggledbits
                        0
                        2
                        34

                      • Error After Upgrade
                        G
                        gwp1
                        0
                        4
                        42

                      • Reset attribute value of entity in event handler
                        R
                        RHCPNG
                        0
                        5
                        113

                      • Need help figuring out how to delay a reset on reaction
                        G
                        gwp1
                        0
                        22
                        353

                      • Way to search for rules (rule state) in other rules
                        T
                        tamorgen
                        0
                        3
                        60

                      • Links to MSR from HA
                        Tom_DT
                        Tom_D
                        0
                        1
                        58

                      • Set Reaction > Script Action
                        wmarcolinW
                        wmarcolin
                        0
                        11
                        348

                      • Wiring Samotech SM308-S into light fitting
                        akbooerA
                        akbooer
                        0
                        2
                        111

                      • Errors after updating to MQTTController build 25139
                        toggledbitsT
                        toggledbits
                        0
                        6
                        205

                      • 🎉 My very first MSR controller: OpenSprinkler
                        therealdbT
                        therealdb
                        5
                        13
                        825

                      • Advice reqeusted to migrate MSR from Bare Metal to Container
                        T
                        tamorgen
                        0
                        5
                        212

                      • Reactor (Multi-System/Multi-Hub) Announcements
                        toggledbitsT
                        toggledbits
                        5
                        122
                        48.7k
                      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