# Can't install i2c or ina219 via palette or manually under nodered 4.0.5

**URL:** <https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467>\
**Category:** General\
**Tags:** docker\
**Created:** [17 October 2024 16:27 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467 "2024-10-17T16:27:53Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [17 October 2024 16:27 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/1 "2024-10-17T16:27:53Z")

</div>

My docker compose node red has been very stable and I have multiple backups which also now fail. Because of calls to i2c in settings.js node red will not start. What happened? Is it an auto upgrade to 4.0.5  
Anyway I've tried to rebuild eg using palette to install contrib-i2c. I get a long error message that starts with:  
npm error code 1  
npm error path /data/node\_modules/i2c-bus  
I get the same when I manually:  
cd DockerIOT/nodered  
dbash  
cd /data  
npm install i2c-bus

I have a near identical setup on another PI running 4.0.0 and it loads fine.  
I'm sorry that I am a bit out of my depth here but would really appreciate some help.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 October 2024 19:17 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/2 "2024-10-17T19:17:52Z")

</div>

Is that the full output from running npm install?

---

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [17 October 2024 19:33 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/3 "2024-10-17T19:33:12Z")

</div>

Hi not sure what you're asking. The error message is quite long eg when trying to install i2c-bus I get a message which begins with a path error:

```auto
2024-10-17T19:30:53.952Z Install : node-red-contrib-i2c 0.9.0

2024-10-17T19:30:53.405Z npm install --no-audit --no-update-notifier --no-fund --save --save-prefix=~ --omit=dev --engine-strict node-red-contrib-i2c@0.9.0
2024-10-17T19:30:57.760Z [err] npm error code 1
2024-10-17T19:30:57.760Z [err] npm error path /data/node_modules/i2c-bus
2024-10-17T19:30:57.760Z [err] npm error command failed
2024-10-17T19:30:57.760Z [err] npm error command sh -c node-gyp rebuild
2024-10-17T19:30:57.760Z [err] npm error gyp info it worked if it ends with ok
2024-10-17T19:30:57.760Z [err] npm error gyp info using node-gyp@8.4.1
2024-10-17T19:30:57.760Z [err] npm error gyp info using node@20.18.0 | linux | arm64
2024-10-17T19:30:57.760Z [err] npm error gyp info find Python using Python version 3.12.7 found at "/usr/bin/python3"
2024-10-17T19:30:57.760Z [err] npm error gyp http GET https://nodejs.org/download/release/v20.18.0/node-v20.18.0-headers.tar.gz
2024-10-17T19:30:57.760Z [err] npm error gyp http 200 https://nodejs.org/download/release/v20.18.0/node-v20.18.0-headers.tar.gz
2024-10-17T19:30:57.760Z [err] npm error gyp http GET https://nodejs.org/download/release/v20.18.0/SHASUMS256.txt
2024-10-17T19:30:57.760Z [err] npm error gyp http 200 https://nodejs.org/download/release/v20.18.0/SHASUMS256.txt
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn /usr/bin/python3
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args [
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '/data/node_modules/node-gyp/gyp/gyp_main.py',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args 'binding.gyp',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '-f',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args 'make',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '-I',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '/data/node_modules/i2c-bus/build/config.gypi',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '-I',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '/data/node_modules/node-gyp/addon.gypi',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '-I',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '/usr/src/node-red/.cache/node-gyp/20.18.0/include/node/common.gypi',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '-Dlibrary=shared_library',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '-Dvisibility=default',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '-Dnode_root_dir=/usr/src/node-red/.cache/node-gyp/20.18.0',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '-Dnode_gyp_dir=/data/node_modules/node-gyp',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '-Dnode_lib_file=/usr/src/node-red/.cache/node-gyp/20.18.0/<(target_arch)/node.lib',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '-Dmodule_root_dir=/data/node_modules/i2c-bus',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '-Dnode_engine=v8',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '--depth=.',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '--no-parallel',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '--generator-output',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args 'build',
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args '-Goutput_dir=.'
2024-10-17T19:30:57.760Z [err] npm error gyp info spawn args ]
2024-10-17T19:30:57.760Z [err] npm error Traceback (most recent call last):
2024-10-17T19:30:57.760Z [err] npm error File "/data/node_modules/node-gyp/gyp/gyp_main.py", line 42, in <module>
2024-10-17T19:30:57.760Z [err] npm error import gyp # noqa: E402
2024-10-17T19:30:57.760Z [err] npm error ^^^^^^^^^^
2024-10-17T19:30:57.760Z [err] npm error File "/data/node_modules/node-gyp/gyp/pylib/gyp/ __init__.py", line 9, in <module>
2024-10-17T19:30:57.760Z [err] npm error import gyp.input
2024-10-17T19:30:57.760Z [err] npm error File "/data/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 19, in <module>
2024-10-17T19:30:57.760Z [err] npm error from distutils.version import StrictVersion
2024-10-17T19:30:57.760Z [err] npm error ModuleNotFoundError: No module named 'distutils'
2024-10-17T19:30:57.760Z [err] npm error gyp ERR! configure error 
2024-10-17T19:30:57.760Z [err] npm error gyp ERR! stack Error: `gyp` failed with exit code: 1
2024-10-17T19:30:57.760Z [err] npm error gyp ERR! stack at ChildProcess.onCpExit (/data/node_modules/node-gyp/lib/configure.js:259:16)
2024-10-17T19:30:57.760Z [err] npm error gyp ERR! stack at ChildProcess.emit (node:events:519:28)
2024-10-17T19:30:57.760Z [err] npm error gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:294:12)
2024-10-17T19:30:57.760Z [err] npm error gyp ERR! System Linux 6.6.31+rpt-rpi-2712
2024-10-17T19:30:57.760Z [err] npm error gyp ERR! command "/usr/local/bin/node" "/data/node_modules/.bin/node-gyp" "rebuild"
2024-10-17T19:30:57.760Z [err] npm error gyp ERR! cwd /data/node_modules/i2c-bus
2024-10-17T19:30:57.760Z [err] npm error gyp ERR! node -v v20.18.0
2024-10-17T19:30:57.760Z [err] npm error gyp ERR! node-gyp -v v8.4.1
2024-10-17T19:30:57.760Z [err] npm error gyp ERR! not ok
2024-10-17T19:30:57.762Z [err] npm error A complete log of this run can be found in: /data/.npm/_logs/2024-10-17T19_30_53_535Z-debug-0.log
2024-10-17T19:30:57.767Z rc=1

```

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 October 2024 20:07 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/4 "2024-10-17T20:07:32Z")

</div>

I think this is the key error

> [@muggins](#):
>
> `ModuleNotFoundError: No module named 'distutils'`

See [distutils is removed in Python 3.12 · Issue #2869 · nodejs/node-gyp · GitHub](https://github.com/nodejs/node-gyp/issues/2869) for the reason. Python 3.12 does not have that module. node-gyp was fixed at version 10, but you only have 8.4.1.

Can you drop Python back to 3.10?

I don't know whether it is possible to upgrade node-gyp or if that will cause other problems.

---

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [17 October 2024 20:22 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/5 "2024-10-17T20:22:19Z")

</div>

Thanks I'll investigate that. I'm still confused as to what changed my stable setup and why when I restored a known good "tar" backup it still had the problem. I would love to lockdown my system so that this cannot happen.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [17 October 2024 20:36 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/6 "2024-10-17T20:36:06Z")

</div>

> [@muggins](#):
>
> I'm still confused as to what changed my stable setup and why when I restored a known good "tar" backup it still had the problem.

I don't know about Docker. Does it build the container from the latest node-red docker image each time you instantiate it? Or something like that? If the latest node-red docker image includes that version of python, but not a later version of node-gyp then possibly that should be changed.  
@knolleary am I talking rubbish here?

---

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [17 October 2024 20:40 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/7 "2024-10-17T20:40:50Z")

</div>

I think you may be right but being new to Docker I don't know how to stop the upgrade (if that's what is happening)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 October 2024 06:47 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/8 "2024-10-18T06:47:30Z")

</div>

Do you have to use Docket? If not, then don't.

---

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [18 October 2024 07:56 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/9 "2024-10-18T07:56:30Z")

</div>

You have a point but all the other elements like Grafana on my Pi are in Docker. I like the idea of everything being in "boxes" and the ease of backup. I'm investigating how to force a download of an earlier version of Nodered to see if that helps.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [18 October 2024 08:25 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/10 "2024-10-18T08:25:21Z")

</div>

Docker can be good if you are using a pre-canned application like Grafana, which does not need to access the host hardware and requires minimum configuration to work. For something like node-red I strongly recommend just using the [recommended install script](https://nodered.org/docs/getting-started/raspberrypi). It will make your life easier. You would not have had this problem for example.

---

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [18 October 2024 08:45 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/11 "2024-10-18T08:45:27Z")

</div>

Yes you're probably right, but I have invested a lot of time learning Docker and getting Nodered to work in that environment. I had considered that this is the way forward.

---

<div class="post-metadata">

**Author:** ![questuk](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/questuk/32/4059_2.png) [@questuk](https://discourse.nodered.org/u/questuk)\
**Post date:** [18 October 2024 13:13 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/12 "2024-10-18T13:13:21Z")

</div>

Hi Muggins

I use my a compose.yaml file and in it i stipulate which Node-RED to use

Here is an example to load a certain version.

Hope this helps 🙂

```auto

services:

# ------------------------------------------------------------------------------------------
# NodeRED
# ------------------------------------------------------------------------------------------ ---

  node-red:

    image: nodered/node-red:3.1.3 # Make sure I am not using 'latest' as it may get changed in the future and break flows or nodes etc.

    # container_name: - not used

```

---

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [18 October 2024 14:06 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/13 "2024-10-18T14:06:34Z")

</div>

Hi,  
I had tried that with various iterations eg 4.0.0 and eventually gave up. However I tried your 3.1.3 and lo and behold it works!! I'm not sure what happens when it pulls down a Nodered docker image. Does it pull down all the node\_modules including the ones that seemed to be causing me issues. I had a known good working backup tar file which I have used before to get me out of trouble, but it seems this time when I restored it, it pulled a newer version from the repository. Next question is: Is this a really old version of Nodered and will that cause problems. Also I had no interaction with nodered prior to it crashing so how did it decide to update itself.  
Anyway thanks a lot.

---

<div class="post-metadata">

**Author:** ![questuk](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/questuk/32/4059_2.png) [@questuk](https://discourse.nodered.org/u/questuk)\
**Post date:** [18 October 2024 14:49 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/14 "2024-10-18T14:49:49Z")

</div>

Hi,

I am very limited in my knowledge of Docker and Node-RED, but I know enough to get it to work 🙂

I do know if you don't add anything after `image: nodered/node-red` it will **Always** download the latest version

I am guessing your TAR file did not have a defined version of Node-RED, so it updated to the latest.

👍

---

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [18 October 2024 15:26 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/15 "2024-10-18T15:26:33Z")

</div>

Yes you're right but why did it upgrade itself without intervention.  
For interest do you stick with version 3.1.3. I see it's about 9 months old.

---

<div class="post-metadata">

**Author:** ![questuk](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/questuk/32/4059_2.png) [@questuk](https://discourse.nodered.org/u/questuk)\
**Post date:** [19 October 2024 12:37 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/16 "2024-10-19T12:37:16Z")

</div>

Hi,

How do you restart Docker and Node-RED what command do use ?

I have been using v3.1.3 for nearly 9 months and because I do not upgrade it, it works even if my PC crashes due to a power failure and I restart Docker.

I may update one day but thats the good thing about docker, I can choose which Node-RED version I use.

I am sure there are other ways, but it has proven reliable for me.

---

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [19 October 2024 19:17 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/17 "2024-10-19T19:17:27Z")

</div>

I use an alias to resart nodered:

```auto
alias drestart="docker compose down; docker compose up -d"

```

---

<div class="post-metadata">

**Author:** ![questuk](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/questuk/32/4059_2.png) [@questuk](https://discourse.nodered.org/u/questuk)\
**Post date:** [20 October 2024 08:01 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/18 "2024-10-20T08:01:53Z")

</div>

> [@muggins](#):
>
> `docker compose up -d`

I think you need to read this [Docker Compose Up Command Explained | Built In](https://builtin.com/articles/docker-compose-up)

It all depends on what you have setup in your docker-compose.yml file.  
Perhaps you could paste the contents of your file here ?

Also this is the command I use to restart Docker, even if my PC has crashed due to power outage.  
Everything works fine, this way it doesn't restart the docker-compose.yml  
`sudo systemctl restart docker`

---

<div class="post-metadata">

**Author:** ![bakman2](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bakman2/32/6207_2.png) [@bakman2](https://discourse.nodered.org/u/bakman2)\
**Post date:** [20 October 2024 08:19 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/19 "2024-10-20T08:19:21Z")

</div>

As was suggested: don't run node-red in docker, unless you know what you are doing.

If you want to make it work, you can create your [own custom docker file](https://github.com/node-red/node-red-docker/tree/master/docker-custom), include all required components manually, build the image and start the container.

---

<div class="post-metadata">

**Author:** ![muggins](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/muggins/32/63013_2.png) [@muggins](https://discourse.nodered.org/u/muggins)\
**Post date:** [20 October 2024 08:35 UTC](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467/20 "2024-10-20T08:35:43Z")

</div>

I use the alias drestart whilst in the nodered folder. In my case:  
cd DockerIOT/nodered  
drestart

I used the build outlined by this guy Antonio

> **[GitHub - fragolinux/DockerIOT: A collection of Docker scripts to setup a complete...](https://github.com/fragolinux/DockerIOT?files=1)**
>
> A collection of Docker scripts to setup a complete IOT development platform

[Next page](https://discourse.nodered.org/t/cant-install-i2c-or-ina219-via-palette-or-manually-under-nodered-4-0-5/92467.md?page=2)
