I2C-bus install fail - RPI Zero W

I have a RPI Zero W with Node-RED.
I am trying to install i2c-oled and it failed. I then tried other nodes and any node that use i2c-bus fail to install.
I have confirmed that the hardware works by using i2cdetect -y 1, even went so far as to install a software i2c on bus 3 and confirmed that it also work.

pi@NanoView:~ $ i2cdetect -y 3
0 1 2 3 4 5 6 7 8 9 a b c d e f
00: -- -- -- -- -- -- -- -- -- -- -- -- --
10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
30: -- -- -- -- -- -- -- -- -- -- -- -- 3c -- -- --
40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
50: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
70: -- -- -- -- -- -- -- --
But i am unable to install any node that use i2c-bus, not sure where to start looking.
Please point me in the right direction.
Here is the error log:
2021-05-16T09:28:01.015Z Install : node-red-contrib-oled 0.2.1

2021-05-16T09:28:01.438Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --production node-red-contrib-oled@0.2.1
2021-05-16T09:28:33.077Z [out]
2021-05-16T09:28:33.077Z [out] > i2c-bus@5.2.2 install /home/pi/.node-red/node_modules/i2c-bus
2021-05-16T09:28:33.077Z [out] > node-gyp rebuild
2021-05-16T09:28:33.077Z [out]
2021-05-16T09:28:42.638Z [out] make: Entering directory '/home/pi/.node-red/node_modules/i2c-bus/build'
2021-05-16T09:28:42.654Z [out] CXX(target) Release/obj.target/i2c/src/i2c.o
2021-05-16T09:28:42.707Z [err] make: *** [i2c.target.mk:113: Release/obj.target/i2c/src/i2c.o] Segmentation fault
2021-05-16T09:28:42.721Z [out] make: Leaving directory '/home/pi/.node-red/node_modules/i2c-bus/build'
2021-05-16T09:28:42.727Z [err] gyp
2021-05-16T09:28:42.733Z [err]
2021-05-16T09:28:42.735Z [err] ERR!
2021-05-16T09:28:42.740Z [err] build error
2021-05-16T09:28:42.746Z [err] gyp
2021-05-16T09:28:42.749Z [err]
2021-05-16T09:28:42.751Z [err] ERR!
2021-05-16T09:28:42.756Z [err] stack Error: make failed with exit code: 2
2021-05-16T09:28:42.756Z [err] gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
2021-05-16T09:28:42.771Z [err] gyp ERR! stack at ChildProcess.emit (events.js:314:20)
2021-05-16T09:28:42.771Z [err] gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
2021-05-16T09:28:42.771Z [err] gyp ERR! System Linux 5.10.17+
2021-05-16T09:28:42.771Z [err] gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
2021-05-16T09:28:42.771Z [err] gyp ERR! cwd /home/pi/.node-red/node_modules/i2c-bus
2021-05-16T09:28:42.774Z [err] gyp
2021-05-16T09:28:42.775Z [err]
2021-05-16T09:28:42.780Z [err] ERR! node -v v12.22.1
2021-05-16T09:28:42.780Z [err] gyp ERR! node-gyp -v v5.1.0
2021-05-16T09:28:42.780Z [err] gyp ERR! not ok
2021-05-16T09:28:42.782Z [err]
2021-05-16T09:28:45.008Z [err] npm
2021-05-16T09:28:45.010Z [err]
2021-05-16T09:28:45.012Z [err] ERR!
2021-05-16T09:28:45.020Z [err] code ELIFECYCLE
2021-05-16T09:28:45.020Z [err] npm ERR! errno 1
2021-05-16T09:28:45.133Z [err] npm
2021-05-16T09:28:45.135Z [err]
2021-05-16T09:28:45.140Z [err] ERR! i2c-bus@5.2.2 install: node-gyp rebuild
2021-05-16T09:28:45.140Z [err] npm ERR! Exit status 1
2021-05-16T09:28:45.140Z [err] npm ERR!
2021-05-16T09:28:45.142Z [err]
2021-05-16T09:28:45.143Z [err] npm
2021-05-16T09:28:45.150Z [err] ERR! Failed at the i2c-bus@5.2.2 install script.
2021-05-16T09:28:45.150Z [err] npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2021-05-16T09:28:45.208Z [err]
2021-05-16T09:28:45.210Z [err] npm
2021-05-16T09:28:45.212Z [err]
2021-05-16T09:28:45.219Z [err] ERR! A complete log of this run can be found in:
2021-05-16T09:28:45.219Z [err] npm ERR! /home/pi/.npm/_logs/2021-05-16T09_28_45_172Z-debug.log
2021-05-16T09:28:45.266Z rc=1

Something is horribly wrong, you appear to have managed to get a segmentation fault running make.

Can you stop node-red then run it again in a terminal and copy/paste the startup log here please, that will give us some information on your system.
Does the system run reliably apart from this issue?

yes - i can only guess it ran out of memory while trying to do that. As @colin suggests try running the install manually from the ~/.node-red directory - and paste the result here (if it fails again).

Hi dceejay

Here is the error from the terminal with NR not running.

pi@NanoView:~/.node-red $ npm install node-red-contrib-oled

i2c-bus@5.2.2 install /home/pi/.node-red/node_modules/i2c-bus
node-gyp rebuild

make: Entering directory '/home/pi/.node-red/node_modules/i2c-bus/build'
CXX(target) Release/obj.target/i2c/src/i2c.o
make: *** [i2c.target.mk:113: Release/obj.target/i2c/src/i2c.o] Segmentation fault
make: Leaving directory '/home/pi/.node-red/node_modules/i2c-bus/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:194:23)
gyp ERR! stack at ChildProcess.emit (events.js:314:20)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
gyp ERR! System Linux 5.10.17+
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/pi/.node-red/node_modules/i2c-bus
gyp ERR! node -v v12.22.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! i2c-bus@5.2.2 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the i2c-bus@5.2.2 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/pi/.npm/_logs/2021-05-16T10_30_24_082Z-debug.log

Hi Colin

As far as i know, it is working fine, i am trying to add i2c to a flow, and this is where i am getting stuck.

Here is the NR Start log

pi@NanoView:~ $ node-red-start

Start Node-RED

Once Node-RED has started, point a browser at http://192.168.2.50:1880
On Pi Node-RED works better with the Firefox or Chrome browser

Use node-red-stop to stop Node-RED
Use node-red-start to start Node-RED again
Use node-red-log to view the recent log output
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

Starting as a systemd service.
16 May 12:39:52 - [info]
Welcome to Node-RED

16 May 12:39:52 - [info] Node-RED version: v1.3.4
16 May 12:39:52 - [info] Node.js version: v12.22.1
16 May 12:39:52 - [info] Linux 5.10.17+ arm LE
16 May 12:39:56 - [info] Loading palette nodes
redPlc rpi_mcp23017 driver V1.0.6 (c) Ocean iiot2k@gmail.com
16 May 12:40:07 - [info] Dashboard version 2.29.0 started at /ui
16 May 12:40:08 - [info] Settings file : /home/pi/.node-red/settings.js
16 May 12:40:08 - [info] Context store : 'default' [module=memory]
16 May 12:40:08 - [info] User directory : /home/pi/.node-red
16 May 12:40:08 - [warn] Projects disabled : editorTheme.projects.enabled=false
16 May 12:40:08 - [info] Flows file : /home/pi/.node-red/flows_NanoView.json
16 May 12:40:08 - [info] Server now running at http://127.0.0.1:1880/
16 May 12:40:08 - [warn]

Your flow credentials file is encrypted using a system-generated key.
If the system-generated key is lost for any reason, your credentials
file will not be recoverable, you will have to delete it and re-enter
your credentials.
You should set your own key using the 'credentialSecret' option in
your settings file. Node-RED will then re-encrypt your credentials
file using your chosen key the next time you deploy a change.

16 May 12:40:09 - [info] Starting flows
16 May 12:40:11 - [error] [mcp23017:@20] error on init
16 May 12:40:12 - [info] Started flows
16 May 12:40:12 - [error] [function:6062eda8.0c2414] TypeError: Cannot read property 'txt' of undefined
16 May 12:40:12 - [info] [mqtt-broker:8bf8026a.48702] Connected to broker: mqtt://localhost:1883
16 May 12:40:12 - [info] [function:6062eda8.0c2414] Status is =undefined

Very odd. Which version of raspbian are you running (use cat /etc/os-release)

Have you recently updated all the raspbian packages to make sure you are up to date?
sudo apt update && sudo apt full-upgrade
That updates all the packages to the latest available for the version of raspbian you are using, but does not update raspbian itself.

Hi Colin

pi@NanoView:~ $ cat /etc/os-release
PRETTY_NAME="Raspbian GNU/Linux 10 (buster)"
NAME="Raspbian GNU/Linux"
VERSION_ID="10"
VERSION="10 (buster)"
VERSION_CODENAME=buster
ID=raspbian
ID_LIKE=debian
HOME_URL="http://www.raspbian.org/"
SUPPORT_URL="RaspbianForums - Raspbian"
BUG_REPORT_URL="RaspbianBugs - Raspbian"

sudo apt update && sudo apt full-upgrade
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Well I have no idea I am afraid. It installs fine on a Zero here, using nodejs 14 but I wouldn't expect it to be be the nodejs version that matters.

I suppose your make might be corrupted, you could try reinstalling that, I think it is installed by build-essential.
sudo apt remove build-essential
Make sure it has removed it by running which make which should not show anything, then
sudo apt install build-essential

Hi Colin / dceejay

I decided to start "Fresh"...
Install RPI lite, setup I2c, update and upgrade, install NR.

And now it works???
Not sure why, as it is the same i did before, hate it when i don't know why it works now and not before.

Thank you for your time and assistance.

Having had the problems you had before I think I would, if possible, have used a new good quality SD card and either ditched the original, or at least marked it as suspect.

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.