Hardware: Rasppberry Pi Model B+ Rev 1.2 with Pro HAT linked to 5 x
DHT22 sensors, 1x BMP280, 3 xLEDs, 1x Buzzer, 1x Button & 2x Reed
Switches
Software: fresh Raspbian Jessie (Linux 4.4.34+ arm LE),
Node.js (4.4.3), Node-Red (0.15.2), Johnny Five (0.10.6), raspi-io
(5.4.1), Wiring Pi (gpio) (2.3.6),
bcm2835 (1.50), node-red-contrib-gpio (0.9.1), npm (4.0.5), git (2.1.4)
Plus these 3 but didn't appear to be successful but may not be material to my problem: raspi, raspi-board, raspi-peripheral
Additional Nodes (from memory compared to initial install): gpio, johnny5, rpi dht22, rpi gpio (original?)
Running Node-Red by: sudo node-red-pi --max-old-space-size=128 --userDir $HOME/.node-red
Unit Testing: All sensors and other I/Os working OK with Python.
Node-Red Initial Testing: node gpio works to switch on an LED.
I then copied some example code into a function node but it fails on line 1:
var raspi = require('raspi-io');
and that gives the error:
ReferenceError: require is not defined (line 1, col 13)
From what I read, require() is built into node.js on the server so it is always available there. Any ideas what could be wrong?
Many thanks,
Alan