Sometimes there is a need to update nodeJS. This is a quick reference how that might be achieved. This is not as straightforward as updating packages.json and running
npm update because some packages require rebuilding from source with the latest node version already in place.
For instance a critical timer bug exists in nodeJS (<=10.8.0) that causes events to stop running after 24.8 days of the app’s run time. An update to 10.9 or later is needed. Run
node -v to find out the installed nodeJS version.
Quick step guide to replacing nodeJS with latest available for the RaspberryPi:
#Stop gateway app and cd to gateway dir: sudo systemctl stop gateway cd /home/pi/gateway #remove old package lock: sudo rm -rf package-lock.json #remove (or rename) node_modules directory: sudo rm -rf node_modules #Update nodejs (removes old node version): sudo wget -O - https://raw.githubusercontent.com/LowPowerLab/RaspberryPi-Gateway/master/.setup/Install-Node.sh | sudo bash #Update npm: sudo npm install -g npm #Re-install all packages/build from source: sudo npm install --unsafe-perm --build-from-source #and clear caches: sudo npm cache verify #Finally: sudo systemctl start gateway