Hi,
Some time ago I installed Node Red on my Raspberry Pi Zero. I think it was Node Red version 1.2.9 or something like that. I have used it for "sandbox'ing" to test different things with ZigBee/MQTT/Tasmota/... and yesterday I needed to upgrade a library for a MQTT part, and it said, my Node Red installation was way out of date. So I started to upgrade...
The short version: I have upgraded nodejs to version 16.3.0, and tried the
to upgrade Node Red. But when the script has finished, Node Red does not work; When I run node-red-start
... I just get the message
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
sh: 0: getcwd() failed: No such file or directory
Node-RED is not yet fully installed. Please re-run the install script again manually.
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
then retry node-red-start
When looking in the log-file ( /var/log/nodered-install.log) it says:
If you want the installer to recreate the systemd script, please delete or rena$
ln: failed to create symbolic link '/usr/bin/python': File exists
Now add launcher to top bar, add cpu temp example, make sure ping works
The user pi' is already a member of gpio'.
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
Building dependency tree...
Reading state information...
python3-rpi.gpio is already the newest version (0.7.0-0.1~bpo10+4).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Allow binding to low ports : n
Memory : 530M
Started : Mon Oct 31 15:11:43 CET 2022
Finished: Mon Oct 31 15:20:53 CET 2022
@zenofmud Thank you for your reply. First regarding the quotes for showing code, That should be fixed now.
It says Codename: buster
The user is pi
The first script bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) was run without sudo while the last one tried sudo npm install -g --unsafe-perm node-red was with sudo
I get
[1] 4857
total 12
drwxr-xr-x 3 root root 4096 Jan 11 2021 .
drwxr-xr-x 18 root root 4096 Jan 11 2021 ..
drwxr-xr-x 9 pi pi 4096 Oct 30 21:06 pi
[1]+ Done cd $HOME/.node-red
I get
Already have nodejs v16.3.0
OLD nodejs 16 :
NEW nodejs :
***************************************
Started : Mon Oct 31 15:11:43 CET 2022
Running for user pi at /home/pi
Found global nodes: :
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
Building dependency tree...
Reading state information...
Package 'nodered' is not installed, so not removed
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Versions: node:v16.3.0 npm:8.19.2
Now install Node-RED
added 8 packages, removed 15 packages, and changed 284 packages in 7m
3.0.2
Now create basic package.json for the user and move any global nodes
Installing extra nodes: node-red-node-pi-gpio@latest node-red-node-random@latest node-red-node-ping@latest node-red-contrib-play-audio@latest node-red-node-smooth@latest node-red-node-serialport@latest node-red-contrib-buffer-parser@latest :
up to date in 23s
Now add the shortcut and start/stop/log scripts to the menu
Now add systemd script and configure it for pi:pi @ /home/pi
Customized systemd script found @ /lib/systemd/system/nodered.service. To prevent loss of modifications, we'll not recreate the systemd script.
If you want the installer to recreate the systemd script, please delete or rename the current script & re-run the installer.
ln: failed to create symbolic link '/usr/bin/python': File exists
Now add launcher to top bar, add cpu temp example, make sure ping works
The user `pi' is already a member of `gpio'.
WARNING: apt does not have a stable CLI interface. Use with caution in scripts.
Reading package lists...
Building dependency tree...
Reading state information...
python3-rpi.gpio is already the newest version (0.7.0-0.1~bpo10+4).
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Allow binding to low ports : n
Memory : 530M
Started : Mon Oct 31 15:11:43 CET 2022
Finished: Mon Oct 31 15:20:53 CET 2022
pi@homeautomatic:/home $ cd $HOME/.node-red & ls -al
[1] 4857
total 12
drwxr-xr-x 3 root root 4096 Jan 11 2021 .
drwxr-xr-x 18 root root 4096 Jan 11 2021 ..
drwxr-xr-x 9 pi pi 4096 Oct 30 21:06 pi
[1]+ Done cd $HOME/.node-red
Oops, my mistake, there should be two & not one. Please run cd $HOME/.node-red && ls -al
and copy/paste the results
and could you try the NR install using bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --node16
This is what I got and you should see something similar:
pi@testpi:~ $ bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered) --node16
Running Node-RED install for user pi at /home/pi on raspbian
This can take 20-30 minutes on the slower Pi versions - please wait.
Stop Node-RED ✔
Remove old version of Node-RED ✔
Remove old version of Node.js ✔ v14.19.1
Install Node.js for Armv6 ✔ v16.18.0 Npm 8.19.2
Clean npm cache ✔
Install Node-RED core ✔ 3.0.2
Move global nodes to local -
Npm rebuild existing nodes ✔
Install extra Pi nodes ✔
Add shortcut commands ✔
Update systemd script - Skipped - existing script is customized.
Any errors will be logged to /var/log/nodered-install.log
All done.
You can now start Node-RED with the command node-red-start
or using the icon under Menu / Programming / Node-RED
Then point your browser to localhost:1880 or http://{your_pi_ip-address}:1880
Started : Tue 1 Nov 03:12:29 EDT 2022
Finished: Tue 1 Nov 03:23:16 EDT 2022
Just FYI : Your settings.js file is different from the latest defaults.
You may wish to run
diff -y --suppress-common-lines /usr/lib/node_modules/node-red/settings.js /home/pi/.node-red/settings.js
to compare them and see what the latest options are.
**********************************************************************************
### WARNING ###
DO NOT EXPOSE NODE-RED TO THE OPEN INTERNET WITHOUT SECURING IT FIRST
Follow the guide at https://nodered.org/docs/user-guide/runtime/securing-node-red
to setup security.
### ADDITIONAL RECOMMENDATIONS ###
- Remove the /etc/sudoers.d/010_pi-nopasswd file to require entering your password
when performing any sudo/root commands:
sudo rm -f /etc/sudoers.d/010_pi-nopasswd
- Change the ownership of its settings file to 'root' to prevent unauthorised changes:
sudo chown root:root ~/.node-red/settings.js
**********************************************************************************
pi@homeautomatic:~ $ cd $HOME/.node-red && ls -al
total 348
drwxr-xr-x 4 pi pi 4096 Oct 30 19:53 .
drwxr-xr-x 9 pi pi 4096 Oct 30 21:06 ..
-rw-r--r-- 1 pi pi 25570 Oct 30 19:53 .config.nodes.json
-rw-r--r-- 1 pi pi 26240 Oct 30 19:53 .config.nodes.json.backup
-rw-r--r-- 1 pi pi 95 Feb 6 2021 .config.runtime.json
-rw-r--r-- 1 pi pi 333 Feb 7 2021 .config.users.json
-rw-r--r-- 1 pi pi 331 Feb 7 2021 .config.users.json.backup
-rw-r--r-- 1 pi pi 21112 Oct 30 19:53 .flows_homeautomatic.json.backup
-rw-r--r-- 1 pi pi 432 Jul 18 2021 .flows_homeautomatic_cred.json.backup
-rw-r--r-- 1 pi pi 20992 Oct 30 19:53 flows_homeautomatic.json
-rw-r--r-- 1 pi pi 504 Jul 18 2021 flows_homeautomatic_cred.json
drwxr-xr-x 3 pi pi 4096 Feb 6 2021 lib
drwxr-xr-x 216 pi pi 12288 Oct 30 20:05 node_modules
-rw-r--r-- 1 pi pi 183252 Oct 31 15:20 package-lock.json
-rw-r--r-- 1 pi pi 783 Oct 30 20:06 package.json
-rw-r--r-- 1 pi pi 13261 Feb 6 2021 settings.js
I did, and got the following
Running Node-RED install for user pi at /home/pi on raspbian
This can take 20-30 minutes on the slower Pi versions - please wait.
Stop Node-RED ✔
Remove old version of Node-RED ✔
Remove old version of Node.js ✔ v16.3.0
Install Node.js for Armv6 ✔ v16.3.0 Npm 8.19.2
Clean npm cache ✔
Install Node-RED core ✔ 3.0.2
Move global nodes to local -
Npm rebuild existing nodes ✔
Install extra Pi nodes ✔
Add shortcut commands ✔
Update systemd script - Skipped - existing script is customized.
Any errors will be logged to /var/log/nodered-install.log
All done.
You can now start Node-RED with the command node-red-start
or using the icon under Menu / Programming / Node-RED
Then point your browser to localhost:1880 or http://{your_pi_ip-address}:1880
Started : Tue Nov 1 16:28:00 CET 2022
Finished: Tue Nov 1 16:40:54 CET 2022
Just FYI : Your settings.js file is different from the latest defaults.
You may wish to run
diff -y --suppress-common-lines /usr/lib/node_modules/node-red/settings.js /home/pi/.node-red/settings.js
to compare them and see what the latest options are.
**********************************************************************************
### WARNING ###
DO NOT EXPOSE NODE-RED TO THE OPEN INTERNET WITHOUT SECURING IT FIRST
Follow the guide at https://nodered.org/docs/user-guide/runtime/securing-node-red
to setup security.
### ADDITIONAL RECOMMENDATIONS ###
- Remove the /etc/sudoers.d/010_pi-nopasswd file to require entering your password
when performing any sudo/root commands:
sudo rm -f /etc/sudoers.d/010_pi-nopasswd
- Change the ownership of its settings file to 'root' to prevent unauthorised changes:
sudo chown root:root ~/.node-red/settings.js
**********************************************************************************
But still, when I afterwards run node-red-start I get
pi@homeautomatic:~/.node-red $ node-red-start
Node-RED is not yet fully installed. Please re-run the install script again manually.
bash <(curl -sL https://raw.githubusercontent.com/node-red/linux-installers/master/deb/update-nodejs-and-nodered)
then retry node-red-start
-rw-r--r-- 1 pi pi 20992 Oct 30 19:53 flows_homeautomatic.json
Are you running Home Automation/Home Automation?
If so, you should be running their install.
I see that the install did not update your node red service file, as you had, apparently, already modified it. Can you show us what is in it please cat /lib/systemd/system/nodered.service
I don't think I am using nvm or n. I don't recall using that.
If I recall it right, I choose the name homeautomatic name myself.
Sure, it shows
pi@homeautomatic:~ $ cat /lib/systemd/system/nodered.service
# systemd service file to start Node-RED
[Unit]
Description=Node-RED graphical event wiring tool
Wants=network.target
Documentation=http://nodered.org/docs/hardware/raspberrypi.html
[Service]
Type=simple
# Run as normal pi user - change to the user name you wish to run Node-RED as
User=pi
Group=pi
WorkingDirectory=/home/pi
Environment="NODE_OPTIONS=--max_old_space_size=256"
# uncomment and edit next line if you need an http proxy
#Environment="HTTP_PROXY=my.httpproxy.server.address"
# uncomment the next line for a more verbose log output
#Environment="NODE_RED_OPTIONS=-v"
# uncomment next line if you need to wait for time sync before starting
#ExecStartPre=/bin/bash -c '/bin/journalctl -b -u systemd-timesyncd | /bin/grep -q "systemd-timesyncd.* Synchronized to time server"'
ExecStart=/usr/bin/env node-red-pi $NODE_OPTIONS $NODE_RED_OPTIONS
#ExecStart=/usr/bin/env node $NODE_OPTIONS red.js $NODE_RED_OPTIONS
# Use SIGINT to stop
KillSignal=SIGINT
# Auto restart on crash
Restart=on-failure
RestartSec=20
# Tag things in the log
SyslogIdentifier=Node-RED
#StandardOutput=syslog
[Install]
WantedBy=multi-user.target
pi@homeautomatic:~ $ cat /proc/cpuinfo
processor : 0
model name : ARMv6-compatible processor rev 7 (v6l)
BogoMIPS : 697.95
Features : half thumb fastmult vfp edsp java tls
CPU implementer : 0x41
CPU architecture: 7
CPU variant : 0x0
CPU part : 0xb76
CPU revision : 7
Hardware : BCM2835
Revision : 9000c1
Serial : 000000005ad7f159
Model : Raspberry Pi Zero W Rev 1.1
If I was you, I would copy the .node-red directory and it’s sub directories to usb drive. I would then uninstall node.js (note you have 16.3.0 while my install got 16.18.0).
I would then run
Can you run which node
then /usr/sbin/node -v ls -l /usr/sbin/node
and copy/paste that whole sequence here, including the lines where you enter the commands please.