This blog entry refers to installing Jessie, Node Red and other utilities on a Pi 2 (not Pi 1 – there is a minor startup issue with Node-Red with that right now) specifically from the November 2015 Jessie image on the Raspberry Pi site.
Grab the November 2015 Jessie image from the Pi Foundation – and put that on an SD – plug it into the Pi – and wait for the Pi to appear on your network at which point you can access it with WinSCP.
The Pi should reboot into Jessie – which will typically be allocated an address on your system. I’d used this Pi elsewhere so I knew the router was likely to allocate 192.168.0.107 – and sure enough – a quick WINSCP and I was back in charge of the new operating system (user pi, password raspberry) all done without ever plugging a keyboard or monitor into the Pi.
First things first – I use winSCP to which I have installed Putty (instructions on the winSCP site) so a quick terminal later, pop up Raspi-Config. If using an SD, the EXPAND FILESYSTEM is a good idea – in my case it was not necessary.
In Raspi-Config change the Pi password, change the Hostname to jessie2 or whatever you want, enable SPI and I2c and force audio through the 3.5mm socket.
A reboot (which in my case showed some error message about spi_bcm2708 – but then it ALWAYS does that until you upgrade) then requires changing the password in winSCP of course.. and you’re soon back in business.
My script is on Bitbucket along with the support script – note this was made for ME – for my requirements – it may need altering a tad for you. I wanted Apache+PHP purely so I could have PHPLITEAdmin which is needed to work with SQLITE3. I also needed Mosquitto with Websockets – and Node-Red with lots of nodes including my own.
After copying the two files into /home/pi I then used WinSCP – looked at the files – right-click properties and ticked the first X (execute) box in each case.
From there one runs (as PI !!) the script
Here is the main script for RPI2
https://bitbucket.org/snippets/scargill/L8zjE
Here is the support script.
https://bitbucket.org/snippets/scargill/ayAG6
Save both in the /home.pi and call the first one whatever_you_like.sh ( I call mine pi-jessie-one.sh)
Do this as user pi with no extra privileges – if using winSCP do not add extra privileges (there’s a way to do it using a sudo command under the sftp section – don’t do it).
Copy the other file and specifically call it hackitt_includes.sh
Run the first one – ./whatever_you_like.sh
LOTS of rubbish, lots of warnings, requests for passwords etc… if asked to say YES/NO.SKIP etc. just use “y” every time.
At the end of all that the Pi will reboot. Go back into a terminal view using WinSCP and Putty – type… node-red-start – and it will fail but you’ll see another instruction for starting the service.
with an editor (WinScp has an editor – I usually associate it with Notepad++) edit /home/pi/.node-red/settings.js
There is an entry that needs amending… see this.
Note that I have uncommented the os.require line and added another with no comma on the end.
Run that. reboot and you’re all done.
At this point there is no security on Node-Red or the Node-Red UI – but they are easily added if you need them – when I figure out how to put that in a script (anyone offering to help) ie insert at an awkward point inside an existing file – then I’ll add that in too.
That’s it – everything should work. It all sounds like a lot but now it all works it really isn’t that much of a pain.
Hallo Pete,
I built up a node red system on the Pi b+ .
Got everything working fine , used your script for older Raspberry Pi’s.
Except:
The server kept on crashing , restarting. Error was indicated in a module
node-red-contrib-freeboard
I uninstalled this module using npm.
Then my system became stable without any hiccups, very usable!
Thanks to you for all the hard work putting everything together , scripts , updates all in all!
Super job.
Here is some indication what happened.
messages in syslog:
in file ~/.node-red/node-modules/node-red-contrib-freeboard/freeboard.js
Log of error in /var/log/syslog
Feb 29 06:23:48 raspberrypikodi Node-RED[1009]: 29 Feb 06:23:48 – [info] Started flows
Feb 29 06:23:59 raspberrypikodi Node-RED[1009]: 29 Feb 06:23:59 – [red] Uncaught Exception:
Feb 29 06:23:59 raspberrypikodi Node-RED[1009]: 29 Feb 06:23:59 – TypeError: undefined is not a function
Feb 29 06:23:59 raspberrypikodi Node-RED[1009]: at interval (/home/pi/.node-red/node_modules/node-red-contrib-freeboard/freeboard.js:71:12)
Feb 29 06:23:59 raspberrypikodi Node-RED[1009]: at wrapper [as _onTimeout] (timers.js:274:14)
Feb 29 06:23:59 raspberrypikodi Node-RED[1009]: at Timer.listOnTimeout (timers.js:119:15)
Feb 29 06:23:59 raspberrypikodi systemd[1]: nodered.service: main process exited, code=exited, status=1/FAILURE
Feb 29 06:23:59 raspberrypikodi systemd[1]: Unit nodered.service entered failed state.
Feb 29 06:24:11 raspberrypikodi Node-RED[1168]: Welcome to Node-RED
in the following code:
function interval(){
var resp=pendingresponses;
pendingresponses=new Array();
for (var i in resp){
resp[i].end(JSON.stringify({}));
^
}
}
the up arrow indicates the position from error log.
I have only removed the culprit causing the crashes, do not have the depth of knowledge to head for the fix.
I am learning usage of node-red , have ESP8266 , Arduino, this second Pi B+ and cloud EMONCMS.org usage.
My Pi is a R/O ( I lost 2.5 HD and SD card with R/W emoncms modules on local Pi B in the past) gateway from RFM12B,RFM69 sensor nodes to emoncms.org account.
I am not sure what this node-red module causing the problem purpose is.
Is there a document with descriptions of the modules purposes and functionality?
There is a huge amount of information available, so far I am at the beginning of my usage of Node-red , any help or pointers would be appreciated.
Thanks so much again for your YouTube videos and all other available material.
Best regards from South Africa
Jasper
Hi
I’ll remove that freeboard node – problem is of course – while I am in control of my script – every script it calls is written by someone else – and if they mess anything up….
Tomorrow I’ll try the script on the new Raspberry Pi 3 – I’m quite looking forward to this..
Many Thanks. Had the same problem and I was afraid it would be a long day of debugging
Anyone help?
Here are some of the errors whilst installing node red. I’m sorry but I don’t do Linux.
gyp WARN EACCES attempting to reinstall using temporary dev dir “/home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/mqtt/node_modules/websocket-stream/node_modules/ws/node_modules/utf-8-validate/.node-gyp”
make: Entering directory ‘/home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/mqtt/node_modules/websocket-stream/node_modules/ws/node_modules/utf-8-validate/build’
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/obj.target/validation.node
COPY Release/validation.node
make: Leaving directory ‘/home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/mqtt/node_modules/websocket-stream/node_modules/ws/node_modules/utf-8-validate/build’
> meshblu@1.32.0 preinstall /home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/meshblu
> node -e “try{require(‘./skip-install.js’)}catch(e){}”
No precompiled binary found
> serialport@2.0.6 install /home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/serialport
> node-pre-gyp install –fallback-to-build
gyp WARN EACCES user “root” does not have permission to access the dev dir “/root/.node-gyp/4.2.4”
gyp WARN EACCES attempting to reinstall using temporary dev dir “/home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/serialport/.node-gyp”
make: Entering directory ‘/home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/serialport/build’
make: *** No rule to make target ‘../.node-gyp/4.2.4/include/node/common.gypi’, needed by ‘Makefile’. Stop.
make: Leaving directory ‘/home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/serialport/build’
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:270:23)
gyp ERR! stack at emitTwo (events.js:87:13)
gyp ERR! stack at ChildProcess.emit (events.js:172:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.1.13-v7+
command “/usr/bin/nodejs” “/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js” “build” “–fallback-to-build” “–module=/home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/serialport/build/Release/node-v46-linux-arm/serialport.node” “–module_name=serialport” “–module_path=/home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/serialport/build/Release/node-v46-linux-arm”
gyp ERR! cwd /home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/serialport
gyp ERR! node -v v4.2.4
gyp ERR! node-gyp -v v3.0.3
gyp ERR! not ok
build error ERR! –
node-pre-gyp ERR! stack Error: Failed to execute ‘/usr/bin/nodejs /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build –fallback-to-build –module=/home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/serialport/build/Release/node-v46-linux-arm/serialport.node –module_name=serialport –module_path=/home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/serialport/build/Release/node-v46-linux-arm’ (1)
node-pre-gyp ERR! stack at ChildProcess. (/home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/serialport/node_modules/node-pre-gyp/lib/util/compile.js:83:29)
node-pre-gyp ERR! stack at emitTwo (events.js:87:13)
node-pre-gyp ERR! stack at ChildProcess.emit (events.js:172:7)
node-pre-gyp ERR! stack at maybeClose (internal/child_process.js:818:16)
node-pre-gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
node-pre-gyp ERR! System Linux 4.1.13-v7+
node-pre-gyp ERR! command “/usr/bin/nodejs” “/home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/serialport/node_modules/.bin/node-pre-gyp” “install” “–fallback-to-build”
node-pre-gyp ERR! cwd /home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/serialport
node-pre-gyp ERR! node -v v4.2.4
node-pre-gyp ERR! node-pre-gyp -v v0.6.18
node-pre-gyp ERR! not ok
Failed to execute ‘/usr/bin/nodejs /usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build –fallback-to-build –module=/home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/serialport/build/Release/node-v46-linux-arm/serialport.node –module_name=serialport –module_path=/home/pi/.node-red/node_modules/node-red-contrib-gpio/node_modules/serialport/build/Release/node-v46-linux-arm’ (1)
npm ERR! Linux 4.1.13-v7+
npm ERR! argv “/usr/bin/nodejs” “/usr/bin/npm” “install” “node-red-contrib-gpio”
npm ERR! node v4.2.4
npm ERR! npm v2.14.12
npm ERR! code ELIFECYCLE
npm ERR! serialport@2.0.6 install: `node-pre-gyp install –fallback-to-build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the serialport@2.0.6 install script ‘node-pre-gyp install –fallback-to-build’.
npm ERR! This is most likely a problem with the serialport package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-pre-gyp install –fallback-to-build
npm ERR! You can get their info via:
npm ERR! npm owner ls serialport
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/pi/.node-red/npm-debug.log
This is what I get and this just keeps repeating.
pi@JMpi:~ $ node-red-start
Start Node-RED
Once Node-RED has started, point a browser at http://10.0.0.50:1880
On Pi Node-RED works better with the Iceweasel browser
Use node-red-stop to stop Node-RED
Use node-red-start to start Node-RED again
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot
Use sudo systemctl disable nodered.service to disable autostart on boot
To find more nodes and example flows – go to http://flows.nodered.org
You may also need to install and upgrade npm
sudo apt-get install npm
sudo npm i -g npm@2.x
Starting Node-RED graphical event wiring tool….
Started Node-RED graphical event wiring tool..
fs.js:549
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: EACCES: permission denied, open ‘/home/pi/.node-red/settings.js’
at Error (native)
at Object.fs.openSync (fs.js:549:18)
at copyFileSync (/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/copy-sync/copy-file-sync.js:21:16)
at Object.copySync (/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:31:7)
at Object. (/usr/lib/node_modules/node-red/red.js:91:20)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:467:10)
nodered.service: main process exited, code=exited, status=1/FAILURE
Unit nodered.service entered failed state.
nodered.service holdoff time over, scheduling restart.
Stopping Node-RED graphical event wiring tool….
Starting Node-RED graphical event wiring tool….
Started Node-RED graphical event wiring tool..
fs.js:549
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: EACCES: permission denied, open ‘/home/pi/.node-red/settings.js’
at Error (native)
and for clarify this is all done as user Pi now.
There must be hundred of people following this blog. Am I the only one having problems? I’ve bought a new SD card, downloaded Jessie (nov), imaged it and carefully followed the instructions above. During the node-red install bit I get numerous “EACCES user root does not have permission……” I don’t know if this is relevant. My PI board claims to be “Raspberry PI 2 Model B V1.1”
The errors I get are similar to the ones from the Berryboot install. Shall I get another PI 2 ?
John
During the Node-Red install – NODE chucks out loads of what look like error messages but are not necessarily error messages. I’ve never understood how it was that in a standard setup, ROOT could possibly NOT have access to everything – if not root then who! However if they’re the ones I’m thinking of it should not matter. Can you screengrab them? Might help someone identify any issues.
As for getting another Pi I should say not.
Thanks for your patience. I love your posts!!
Thank you. I’m normally even more patient but if you saw the limited space I have to work in here while we await the arrival of my new office… right I’ve completely scrapped for now the section on Berryboot – until it is possible to pick specific images in there. If you look on YouTube for “Peter Oakes” – like me he has now used this script on the November Jessie installation several times. I have a similar script in the same place (Bitbucket) for the old Pi1 and that works exactly the same except for an issue with Node-Red startup which hopefully will soon be fixed (Node-Red works, I just can’t get the startup script to work on Pi1. I may yet go back to using PM2.
My mistaken interpretation of this was that the script in the caption caused problems but after an update and reboot then it worked. sorry. Anyway I did ignore it but still no success. I might try downloading the Jessie November image and take it from there.
thanks
John
It probably does not help that Microsoft Writer is showing the script section (not to be used) completely differently to how it appears in the editor.
I am re-doing the script for a straight installation from the November Jessie image – I’ve opened up a can of worms with the Berryboot installation as I have no control over what version of Jessie they put on there. On reflection not too good an idea. The revised blog entry will be up shortly.
Before I give up can I ask again if this bit of script is important.?
#!/bin/bash PATH=”/sbin:/usr/sbin:$PATH” export PATH sudo apt-get -yq update # sudo apt-get -yq upgrade sudo apt-get -yq dist-upgrade # sudo apt-get autoremove
I’m looking at that piece of script and i have no idea where you got that from.
The only place #!/bin/bah occurs in my script is on the top line.
If you are referring to the caption in the article above, the line below says
When I tried this I had all sorts of problems and ultimately this failed so I ran:
sudo rpi-update – and rebooted – THEN the script worked.
So the short answer is no – do NOT use that extract – it is there for reference only. Run my script..
type node-red-start and read the instruction to make it run on boot.
Pete
5 complete installs now and the most recent used your latest PI2 script. I still get the same errors when running “node-red-start” The only variation from your instructions above is the bit about “/usr/local/bin”
which I left out. Anyway back to Wheezy which I did manage successfully to run.
thanks for all your help.
John
I’m at a loss John – the RPI2 script definitely works if you start with the November 2015 Jessie image from RPI. When you reboot after running the script… type node-red-start – and it will start and tell you what to do in order to get it to run at boot. That is all. it took me some time to move from Wheezy….
Pete I am running RPI2
In that case I’m confused – the RPI2 script does not have the line that is causing an issue.
RPI2 script is here
https://bitbucket.org/snippets/scargill/L8zjE
Both of them need an update as one of the nodes needs SUDO
I’l have that done by end of evening – just checking it now…. but it can be added later anyway.
When the script is done – node-red-start should start up node-red and you can see in there the command you need to run to make it boot up at boot time… I plan to add that to the end of the script.
I don’t suppose you’re running the wrong script – the Pi2 installation doesn’t HAVE that line starting ln (which, it would seem I’m going to have to add SUDO to)….
This is the script you should be using… for clarification.. for RPI2 ONLY
https://bitbucket.org/snippets/scargill/L8zjE/raspbian-jessie-and-node-red-script-for
Before I run the script again I have just tried (in an effort to backup my clean Jessie install) to run Berryboot via TightVNC. Now I repeatedly get “Connection has been gracefully closed” Aghhhhhhh
I’m still a little confused… did I say little? Do I ignore the bit about /usr/local/bin altogether?
Spotted a bug in the old RPI script…. I got some advice on this and they got the address wrong – then I managed to leave sudo off..
You MIGHT get away with running this after you are done
sudo ln -fs /usr/local/bin/node /usr/bin/node
Better to redo the installation (I know it takes ages, FAR longer than an RPI2) – with the update I’ve put on Bitbucket…. I’m doing the same – should be done later tonight.
I was absent from school the day they did Linux…………
Now on my 4th attempt from scratch
Regarding the bit about loading a file in
/usr/local/bin
Is that an .sh file? How do you run it? When I try to create a file at that location using WinSCP I get “permission denied”
Am I the only one who is struggling?
Sorry to be a nuisance but I love this fantastic stuff Pete is doing and can’t wait to get stuck into node-red.
John
I must’ve been off school on the same day. Erm, the only bit about /usr/local/bin – is a shortcut – you don’t do anything…. essentially (and I only found this out this morning) – it tirns out that Node is installing files in a different place in old pi to the new pi2. So when the Node-Red script tries to start, it finds nothing in /usr/local/bin…. you happened to hit on teh one line that has not been properly tested. BUT as it happens, I made an installation on a 32GB card which I need back so right now as I speak, an installation is taking place on my old PI. If it presents questions I’ll come back to you – meanwhile – can you tell me exactly what is happening at this point? That line is just supposed to run. Perhaps it should have had a “sudo” prefix. I’ll soon find out.
I’m referring to line 109 in the script. Are you? The ln command
https://wiki.debian.org/ln
No it’s a PI 2. I assume then that this is not the expected error message you referred to.
Pete
thanks, on the site someone had commented that expand filesystem is not necessary with Berryboot.
Anyway another problem. After a full install as per your script and then “node-red-start” I get this:
Is this the expected error message? I can’t get it to run.
thanks… John
Start Node-RED
Once Node-RED has started, point a browser at http://10.0.0.50:1880
On Pi Node-RED works better with the Iceweasel browser
Use node-red-stop to stop Node-RED
Use node-red-start to start Node-RED again
Use sudo systemctl enable nodered.service to autostart Node-RED at every boot
Use sudo systemctl disable nodered.service to disable autostart on boot
To find more nodes and example flows – go to http://flows.nodered.org
You may also need to install and upgrade npm
sudo apt-get install npm
sudo npm i -g npm@2.x
at copyFileSync (/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/copy-sync/copy-file-sync.js:21:16)
at Object.copySync (/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:31:7)
at Object. (/usr/lib/node_modules/node-red/red.js:91:20)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:467:10)
nodered.service: main process exited, code=exited, status=1/FAILURE
Unit nodered.service entered failed state.
fs.js:549
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
^
Error: EACCES: permission denied, open ‘/home/pi/.node-red/settings.js’
at Error (native)
at Object.fs.openSync (fs.js:549:18)
at copyFileSync (/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/copy-sync/copy-file-sync.js:21:16)
at Object.copySync (/usr/lib/node_modules/node-red/node_modules/fs-extra/lib/copy-sync/copy-sync.js:31:7)
at Object. (/usr/lib/node_modules/node-red/red.js:91:20)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Function.Module.runMain (module.js:467:10)
nodered.service: main process exited, code=exited, status=1/FAILURE
Unit nodered.service entered failed state.
I don’t suppose you did this on an original Pi as against a Pi2 as that is exactly what I would expect on an original Pi – the script will not work with the original. I’ve just updated the script on BitBucket and included a version for the older Pis…..
Pete
Maybe it’s my lack of understanding but…
I load Berryboot to a 16G card
Load “Jessie”
load raspi-config and attempt expand filesystem.
I get “not an sd card. Don’t know how to expand”
Should I ignore this?
thanks
John
No it’s not your lack of understanding – that would fox me too. I got some strange message but then a second later it said done. If this is failing then I suggest the Raspberry Pi site is the place to get answers. I’m finding RPI people to be quite helpful.
Pete
In your earlier script setup you generated a root password. I’ve tried it now under Jessie and although it seems to accept password for root I get “access denied” when logging in.
John
The earlier script was for Wheezy, this is for Jessie.
For reasons well beyond me – the designers of Wheezy decided life was far too easy. By default in Jessie, external access (ie not on the board) to root is prohibited. This means going into NANO and altering a file – but as you don’t have remote root access – you can’t do that headlessly which completely defeats the object of a headless installation – it’s the most stupid design decision I’ve come across in years.
Here is now to get around it.
https://www.raspberrypi.org/forums/viewtopic.php?f=29&t=110233
I decided to stick with PI in my new script and you have to do really stupid things like write stuff to a temporary directory then use sudo to copy the file across…