I've managed to use MSR UI on iOS devices to some degree*, so that although UI elements (e.g. rule sets) are not visible in portrait mode, you've seen them in landscape. Now with recents builds (24302) this does not work anymore, elements (rule sets, entities) are not anymore visible in landscape mode.
Does anyone have similar experiences? Using iOS 18 and Safari/Chrome browser.
( *Drag & drop of rule conditions have never worked on a mobile)
Hi @toggledbits,
I have lots of logs with this:
<Engine:ERR> Assignment to alarm ignored -- expression-driven global cannot be set by assignmentAny hints to where look at to avoid this? Thanks.
Hi @toggledbits
I'd like to update my controllers with these new features, but I'm struggling to find any guidance in the docs - and in general to understand the context.
Could you please elaborate more? Thanks.
I have the following ACL defined:
groups: admin: users: - admin applications: true api_acls: # This ACL allows users in the "admin" group to access the API - url: "/api" group: admin allow: true log: true # This ACL allows anyone/thing to access the /api/v1/alive API endpoint - url: "/api/v1/alive" allow: trueAnd I have authenticated to MSR as "admin" user. However, I'm getting "access denied" when trying to access http://*******:8111/api/v1/log
So what I'm missing, is my ACL incorrectly defined?
Using build 24302 on Docker.
Thanks to @toggledbits for adding a custom CSS. I've started doing a darker Reactor style.
Here's the file: https://gist.github.com/dbochicchio/825098ac13b7f8cac22012eae37ff7ce
A couple of things are still too bright and I'll eventually catch-up. Just place it under your /config directory, naming the file as customstyles.css. Hard refresh your browser.
Hi!
In Home Assistant I sometimes uses the TTS, either to my Sonos or Google speakers. With reactor in Vera I also use TTS.
But in MSR I can't select the TTS-service. It's simply not there. Am I missing something, or is this the case, so far?
Thanks!
/Fanan
Hi
I have just connected a bunch of EzloPi controllers to MSR to import some ESP based devices etc.
They all seemed to have worked and imported in to MSR apart from I have one missing device. It is a Digital Gas Sensor device.
This is how that device looks in the Ezlo API.
Devices Info:
_id: "10696001" deviceTypeId: "ezlopi" parentDeviceId: "10696000" category: "level_sensor" subcategory: "" gatewayId: "457a5069" batteryPowered: false name: "Gas Sensor Digital" type: "sensor" reachable: true persistent: true serviceNotification: false armed: false roomId: "" security: "no" ready: true status: "idle" parentRoom: true protectConfig: "default"Items Info:
_id: "20696001" deviceId: "10696001" hasGetter: true hasSetter: false name: "smoke_density" show: true valueType: "substance_amount" scale: "parts_per_million" value: 2.7472610473632812 valueFormatted: "2.75" status: "idle"There is also an Analog Gas sensor that one did import in to MSR OK.
68d63dab-b871-4f44-912b-cf6e0b9eb4c6-image.png
Devices Info:
_id: "10696000" deviceTypeId: "ezlopi" parentDeviceId: "10696000" category: "security_sensor" subcategory: "gas" gatewayId: "457a5069" batteryPowered: false name: "Gas Sensor Analog" type: "sensor" reachable: true persistent: true serviceNotification: false armed: false roomId: "" security: "no" ready: true status: "idle" parentRoom: true protectConfig: "default"Items Info:
_id: "20696000" deviceId: "10696000" hasGetter: true hasSetter: false name: "gas_alarm" show: true valueType: "token" enum: 0: "no_gas" 1: "combustible_gas_detected" 2: "toxic_gas_detected" 3: "unknown" valueFormatted: "no_gas" value: "no_gas" status: "idle"And this is how this MQ2 Gas Sensor looks like on their dashboard:
Digital
cb77dfa3-4af5-4d06-9635-89207a716a89-image.png
Analog
4fb4da1b-e946-4b89-876c-bcd9f5699b6c-image.png
They have an EzloPi website here you can create your own sensor projects using ESP boards, which is very interesting stuff!
And I just wrote on the Ezlo forum here, how to connect an EzloPi controller to MSR.
THANKS.
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.A couple of things for you @toggledbits, since you mentioned that this release has new features and some tweaks are expected.
Local expressions cannot be deleted. Pushing the X button has no effect for me.
When cloning an entity action, the result is strange (first is cloned one, second is the original action):
a92ea094-9e2c-4aaa-bf47-2d07a6ffdbd0-image.png
When changing the action on the cloned element, the params are added to the original one. See screenshot:
92ac3011-83c8-466b-bd23-47d483ad7a52-image.png
Dark theme has a couple of strange contrasts. One is visible in the previous screenshots (white text on yellow background). Another one is in groups (blue text on blue background):
9b3c4988-53ef-44e6-9672-30e744cacb75-image.png
Overall, I found blue, yellow, red and green (in buttons and forms) to be too bright.
On the bright side:
I love the new script action: thank you! The dark theme is a great start to avoid getting blinded at night I promise I'll try very soon the new features around actions. Thanks!@toggledbits
I just upgraded to version MSR 24293, bare metal running on Fedora. Upon restart, I am getting a error banner:
I followed the new directions about npm
npm i --no-save --no-package-lock --omit dev
Any idea what the issue is?
Seems like switching the UI to the newly added dark mode (thank you for this) does nothing. The UI stays in light mode and only a few buttons turn into dark mode (see screenshot)
Things I have tried:
Hard refresh
Different browser
Different computer
Restarting Reactor
Failed troubleshooting attempts:
No errors in Chrome console
No relevant errors in Reactor log (can still PM the full log file)
Reactor version: latest-24293-ea42a81d
Hardware: Odroid N2+
Linux version: Ubuntu 24.04.1 LTS
3df2806f-9146-485b-9ec1-d056e91cefe5-image.png Dark mode enabled
ff823023-c079-4684-b01f-d6ac6527d31a-image.png Light mode enabled
Good morning,
I have a service MQTT service that needs a restart occasionally. The add-on (Smartbed MQTT) is for the smart bed base for my bed. It has a "safety light" that I can control from HAAS & MSR as a light entity, and also moves the head of the bed to a preset at bedtime, and then lies it back flat in the morning The problem is, from time to time, the light becomes "unavailable" Restarting from the Add-ons tab in HAAS always fixes it, but I should be able to detect when it happens when "light.tempur_pedic_safety_lights" is not true or false, i.e., unavailable.
What I don't know how to do is how to restart that service. Does anybody have experience in restarting add-ons from MSR?
Running:
Reactor (Multi-hub) latest-24212-3ce15e25 ZWaveJSController [0.1.24232]HAAS:
RPi5-64 (8GB) Core 2024.7.3 Supervisor 2024.08.0 Operating System 13.0 Frontend 20240710.0Hi!
Is it possible to generate two additional log files, the first being the replica of what is displayed on screen by the Rule History widgets and the other with Recently Changed Entities?
And could I configure the generation of one file per day, and delete the older ones? For example, store the last 5 days?
And being more ambitious, does Windget have an icon to open these TXT files in the navigated?
Well, we're approaching Christmas, so here's my request to Santa Claus @toggledbits 🙂
Hi @toggledbits
I'm working on a controller to generate llm response from a prompt in reactor. I have http response coming thru an http request action at the moment, capturing the response inside a local variable. So, it's practically sync.
I want to create a controller, so I don't have to rely on a proxy (and have a simpler architecture), and duplicate absurd http actions, but AFAIK in the current implementation, actions are async only. But if I have multiple requests going on, I cannot be sure what it's really inside an attribute. I also thought that something like a correlation id when sending the request could be used to identity multiple responses, but I wanted to double check with you before starting with something too complicated. I also noticed that some actions in home assistant (ie forecast) are sync and I'm wondering if you have any plan or hint to address this situation. Thanks.
Thanks.
@togglebits I am curious as to why the tilt_sensor.state (primary) = NULL. I believe it should show true or false. I have to use binary_sensor.state instead in my rules.
Again, not sure if this is related to Reactor/ZwaveJSController implementation or the actual Z-Wave JS UI docker version. I have copied, below, the attributes of the tilt sensor in hopes it can help.
Thanks in advance.
Reactor version 23302
ZWaveJSController version 23254
Z-Wave JS UI version 9.3.0.724519f
zwave-js version 12.2.3
@toggledbits I have noticed after upgrading both Reactor and ZWaveJSController to version 24257 that two of my devices/entities, TILT-ZWAVE2.5-ECO and Zooz ZSE18, had their entity re-named in an unusual way and also appears to be duplicated.
Reactor version 24257
ZWaveJSController version 24257
Z-Wave JS UI version 9.18.1
zwave-js version 13.2.0
Vestibule Motion Sensor State attributes/partial screenshot of entities it created. All entities have the same attributes.
motion_sensor.state=true x_zwave_values.Notification_Home_Security_Motion_sensor_status=8 zwave_device.capabilities=[113] zwave_device.endpoint=0 zwave_device.failed=null zwave_device.manufacturer_info=null zwave_device.node_id=23 zwave_device.valueId=[113,"Notification","Home Security","Home Security","Motion sensor status","Motion sensor status"] zwave_device.version_info=nullTilt Sensor Door State and Tilt Sensor Door State Simple attributes/partial screenshot of entities it created. All entities have similar attributes with exception of x_zwave_values.Notification_Access_Control_Door_State = 22 or 23.
tilt_sensor.state=true x_zwave_values.Notification_Access_Control_Door_state=22 zwave_device.capabilities=[113] zwave_device.endpoint=0 zwave_device.failed=null zwave_device.manufacturer_info=null zwave_device.node_id=24 zwave_device.valueId=[113,"Notification","Access Control","Access Control","Door state","Door state"] zwave_device.version_info=null tilt_sensor.state=true x_zwave_values.Notification_Access_Control_Door_state_simple=22 zwave_device.capabilities=[113] zwave_device.endpoint=0 zwave_device.failed=null zwave_device.manufacturer_info=null zwave_device.node_id=24 zwave_device.valueId=[113,"Notification","Access Control","Access Control","Door state (simple)","Door state (simple)"] zwave_device.version_info=null tilt_sensor.state=false x_zwave_values.Notification_Access_Control_Door_state=23 zwave_device.capabilities=[113] zwave_device.endpoint=0 zwave_device.failed=null zwave_device.manufacturer_info=null zwave_device.node_id=24 zwave_device.valueId=[113,"Notification","Access Control","Access Control","Door state","Door state"] zwave_device.version_info=null tilt_sensor.state=false x_zwave_values.Notification_Access_Control_Door_state_simple=23 zwave_device.capabilities=[113] zwave_device.endpoint=0 zwave_device.failed=null zwave_device.manufacturer_info=null zwave_device.node_id=24 zwave_device.valueId=[113,"Notification","Access Control","Access Control","Door state (simple)","Door state (simple)"] zwave_device.version_info=nullI'm slowly migrating all my stuff to MQTT under MSR, so I have a central place to integrate everything (and, in a not-so-distant future, to remove virtual devices from my Vera and leave it running zwave only).
Anyway, here's my reactor-mqtt-contrib package:
Contrib MQTT templates for Reactor. Contribute to dbochicchio/reactor-mqtt-contrib development by creating an account on GitHub.
Simply download yaml files (everything or just the ones you need) and you're good to go.
I have mapped my most useful devices, but I'll add others soon. Feel free to ask for specific templates, since I've worked a lot in the last weeks to understand and operate them.
The templates are supporting both init and query, so you have always up-to-date devices at startup, and the ability to poll them. Online status is supported as well, so you can get disconnected devices with a simple expression.
Many-many thanks to @toggledbits for its dedication, support, and patience with me and my requests 🙂
Help updating node.js for bare metal install
-
I just read on the last MSR update that we need to update node.js. I just checked and on my Linux Debian machine its version 16.17.0.
I then at the terminal ran this command but it says I already have the latest version of node.js which doesn't seem right.
sudo apt-get install nodejs Reading package lists... Done Building dependency tree Reading state information... Done nodejs is already the newest version (16.17.0-deb-1nodesource1). 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Any tips?
Thanks
EDIT:
I ran these commands instead to update all packages.
sudo apt update
then
sudo apt upgrade
I then did a node -v and now its version 16.20.2
However the announcement says "all nodejs versions earlier than 18 are now end-of-life".
EDIT2:
I then tried these commands:
npm install -g n
n latest
Now a node -v says its version 21.4.0
However after restarting MSR I still get this alert error:
-
Looks like it changed the path of the node installation? Maybe MSR is still looking at the old path?
This was from the terminal output:installing : node-v21.4.0 mkdir : /usr/local/n/versions/node/21.4.0 fetch : https://nodejs.org/dist/v21.4.0/node-v21.4.0-linux-x64.tar.xz copying : node/21.4.0 installed : v21.4.0 (with npm 10.2.4) Note: the node command changed location and the old location may be remembered in your current shell. old : /usr/bin/node new : /usr/local/bin/node If "node --version" shows the old version then start a new shell, or reset the location hash with: hash -r (for bash, zsh, ash, dash, and ksh) rehash (for csh and tcsh)
There is a file called "node" under both usr/bin and usr/local/bin directories, I can see these using WinSCP to look at the file structure.
This was also in the terminal before the above:
npm install -g n added 1 package, and audited 2 packages in 2s found 0 vulnerabilities npm notice npm notice New major version of npm available! 8.19.4 -> 10.2.5 npm notice Changelog: https://github.com/npm/cli/releases/tag/v10.2.5 npm notice Run npm install -g npm@10.2.5 to update! npm notice root@HP-Thin01:~# ^C root@HP-Thin01:~# npm install -g npm@10.2.5 npm ERR! code EBADENGINE npm ERR! engine Unsupported engine npm ERR! engine Not compatible with your version of node/npm: npm@10.2.5 npm ERR! notsup Not compatible with your version of node/npm: npm@10.2.5 npm ERR! notsup Required: {"node":"^18.17.0 || >=20.5.0"} npm ERR! notsup Actual: {"npm":"8.19.4","node":"v16.20.2"} npm ERR! A complete log of this run can be found in: npm ERR! /root/.npm/_logs/2023-12-08T14_42_53_914Z-debug-0.log
I am stuck now and don't know how to fix this?
Thanks
-
This is the contents of that log file it mentioned:
0 verbose cli /usr/bin/node /usr/bin/npm 1 info using npm@8.19.4 2 info using node@v16.20.2 3 timing npm:load:whichnode Completed in 1ms 4 timing config:load:defaults Completed in 7ms 5 timing config:load:file:/usr/lib/node_modules/npm/npmrc Completed in 3ms 6 timing config:load:builtin Completed in 3ms 7 timing config:load:cli Completed in 10ms 8 timing config:load:env Completed in 1ms 9 timing config:load:project Completed in 26ms 10 timing config:load:file:/root/.npmrc Completed in 10ms 11 timing config:load:user Completed in 11ms 12 timing config:load:file:/usr/etc/npmrc Completed in 1ms 13 timing config:load:global Completed in 1ms 14 timing config:load:validate Completed in 1ms 15 timing config:load:credentials Completed in 6ms 16 timing config:load:setEnvs Completed in 4ms 17 timing config:load Completed in 73ms 18 timing npm:load:configload Completed in 74ms 19 timing npm:load:mkdirpcache Completed in 4ms 20 timing npm:load:mkdirplogs Completed in 1ms 21 verbose title npm install npm@10.2.5 22 verbose argv "install" "--global" "npm@10.2.5" 23 timing npm:load:setTitle Completed in 5ms 24 timing config:load:flatten Completed in 14ms 25 timing npm:load:display Completed in 24ms 26 verbose logfile logs-max:10 dir:/root/.npm/_logs 27 verbose logfile /root/.npm/_logs/2023-12-08T14_42_53_914Z-debug-0.log 28 timing npm:load:logFile Completed in 25ms 29 timing npm:load:timers Completed in 0ms 30 timing npm:load:configScope Completed in 0ms 31 timing npm:load Completed in 138ms 32 silly logfile start cleaning logs, removing 1 files 33 silly logfile done cleaning log files 34 http fetch GET 200 https://registry.npmjs.org/npm 126ms (cache hit) 35 timing command:install Completed in 275ms 36 verbose stack Error: Unsupported engine 36 verbose stack at Object.checkEngine (/usr/lib/node_modules/npm/node_modules/npm-install-checks/lib/index.js:14:25) 36 verbose stack at Install.exec (/usr/lib/node_modules/npm/lib/commands/install.js:109:16) 36 verbose stack at async module.exports (/usr/lib/node_modules/npm/lib/cli.js:78:5) 37 verbose pkgid npm@10.2.5 38 verbose cwd /root 39 verbose Linux 4.19.0-21-amd64 40 verbose node v16.20.2 41 verbose npm v8.19.4 42 error code EBADENGINE 43 error engine Unsupported engine 44 error engine Not compatible with your version of node/npm: npm@10.2.5 45 error notsup Not compatible with your version of node/npm: npm@10.2.5 45 error notsup Required: {"node":"^18.17.0 || >=20.5.0"} 45 error notsup Actual: {"npm":"8.19.4","node":"v16.20.2"} 46 verbose exit 1 47 timing npm Completed in 774ms 48 verbose code 1 49 error A complete log of this run can be found in: 49 error /root/.npm/_logs/2023-12-08T14_42_53_914Z-debug-0.log
-
So i ran into almost the exact same issue and this is how I managed to update NodeJS. Instead of running
sudo apt update
andsudo apt upgrade
I followed the install instructions on NodeJS Github.To make Reactor happy I copied the path the old
nodejs
file was in and in my case it was/home/arman/.local/lib/nodejs
I believe yours looks like it should be the same. Before doing anything copy and delete theNodeJS
folder and put it somewhere where you can access it again if you run into any issues. Following the steps replace anywhere where it says/usr/local/lib/nodejs
with/home/{user}/.local/lib/nodejs
. This is where I have a band-aid repair to get Reactor back up and working. I renamed the new folder in the/home/{user}/.local/lib/nodejs
directory from the new version of NodeJS to the previous version. In my case it I changed it fromnode-v20.10.0-linux-armv7l
tonode-v16.15.1-linux-armv7l
. Then Reactor was happy and no error saying I need to update Node. This is a temporary fix however.I am no Linux expert so please take my advice with caution lol!
-
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.
-
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.
-
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. -
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.
-
@wmarcolin That may have worked, but it's not strictly right and may lead to complications down the road, like versions of
node
andnpm
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 (unlessapt
oryum
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 thePATH
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
andnpm
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 typingnode
). 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 directorynode-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 asroot
) :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'sbin
subdirectory to the current directory (which is our/usr/local/bin
). Thels
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 thePATH
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 thePATH
. 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 doingecho $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 subdirectoriesbin
,lib
andlib/nodejs
within just like we would have in/usr/local
. At this point, the current directory is~/.local/lib/nodejs
, and thewget
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-tar
ing 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 withecho $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 yourPATH
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 correctnode
executable inExecStart
(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 doingwhich node
is only the tip of the iceberg. You need to then dols -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.
-
@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
-
@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.
-
Super thanks for the master class!!!!
-