# Struggling to install node-red-contrib-modbus on Raspberry Pi 4 (Debian + Docker Compose) - gyp: Undefined variable error

**URL:** https://discourse.nodered.org/t/struggling-to-install-node-red-contrib-modbus-on-raspberry-pi-4-debian-docker-compose-gyp-undefined-variable-error/98158
**Category:** General
**Tags:** docker
**Created:** [15 July 2025 19:59 UTC](https://discourse.nodered.org/t/struggling-to-install-node-red-contrib-modbus-on-raspberry-pi-4-debian-docker-compose-gyp-undefined-variable-error/98158 "2025-07-15T19:59:40Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![maciejbilu](https://avatars.discourse-cdn.com/v4/letter/m/278dde/32.png) [@maciejbilu](https://discourse.nodered.org/u/maciejbilu)
#### Post date: [15 July 2025 19:59 UTC](https://discourse.nodered.org/t/struggling-to-install-node-red-contrib-modbus-on-raspberry-pi-4-debian-docker-compose-gyp-undefined-variable-error/98158/1 "2025-07-15T19:59:40Z")

</div>

Hello everyone,

I'm facing significant challenges trying to get `node-red-contrib-modbus` working in my Node-RED setup on a Raspberry Pi 4. Previously, when I used Home Assistant Supervised (which includes Node-RED as an add-on), everything worked flawlessly. However, with my current independent Docker Compose setup, I'm hitting a wall.

**My Setup:**

- **Hardware:** Raspberry Pi 4 (ARM64 architecture)
- **Operating System:** Debian (confirmed as Debian 11 Bullseye inside the container)
- **Node-RED setup:** Docker Compose, pulling an official `nodered/node-red` image.

**My Goal:** To successfully install and use `node-red-contrib-modbus`, which relies on `serialport` for communication with a `/dev/ttyUSB0` device (properly mapped in `docker-compose.yml`).

**Steps Taken & Problems Encountered:**

1. **Initial Image Problems:** Initially, some official `nodered/node-red` tags for ARM64 defaulted to Alpine Linux, which lacked Python 2 (needed for `node-gyp` compilation).
2. **Achieved Debian Bullseye:** After several attempts with different tags/strategies, I successfully got Node-RED running in a Debian 11 (Bullseye) based container.
3. **Python 2 Confirmed:** I've confirmed that Python 2.7.18 is installed and accessible within the container.
4. **`npm install` Failure (Current Blocking Issue):** When attempting to install `node-red-contrib-modbus` using `npm install node-red-contrib-modbus@5.43.0 --unsafe-perm --build-from-source` (run as `node-red` user in `/data` directory), it consistently fails with the following error related to `@serialport/bindings-cpp` compilation:`npm error code 1 npm error path /data/node_modules/@openp4nr/modbus-serial/node_modules/@serialport/bindings-cpp npm error command failed npm error command sh -c node-gyp-build npm error gyp info using node-gyp@3.8.0 npm error gyp info using node@20.19.0 | linux | arm64 npm error gyp: Undefined variable standalone_static_library in binding.gyp while trying to load binding.gyp npm error gyp ERR! configure error npm error gyp ERR! stack Error: `gyp` failed with exit code: 1`
5. **Troubleshooting Steps Attempted for `node-gyp`:**

- **Updating `node-gyp` globally:** I ran `npm install -g node-gyp@latest` as `root` inside the container, which succeeded. However, the subsequent `npm install` for Modbus _still_ reports using `node-gyp@3.8.0`, indicating it's likely a local dependency of the module overriding the global version.
- **Clearing `npm` cache:** `npm cache clean --force` was performed.
- **Fixing cache permissions:** Addressed `EACCES` errors in `/data/.npm` by running `chown -R 1000:1000 "/data/.npm"` as `root`.
- **Deleting problematic module directory:** `rm -rf node_modules/@openp4nr/modbus-serial/node_modules/@serialport/bindings-cpp` was performed before retrying `npm install`.

**My understanding of the problem:** It appears there's an incompatibility between Node.js v20.19.0 and `node-gyp@3.8.0` (which `serialport` is trying to use for compilation). The `standalone_static_library` variable seems to be the core issue during the `gyp` configuration step.

**My Question:** Given this situation, how can I reliably get `node-red-contrib-modbus` to compile and work in this Docker Compose environment on my Raspberry Pi 4?

- Are there specific official `nodered/node-red` Docker image tags for ARM64 that are Debian-based and use Node.js 16 or 18 (which might have better `node-gyp` compatibility)?
- Or is a custom `Dockerfile` the only guaranteed way to achieve this, and if so, what would be the recommended `Dockerfile` configuration (including Node.js version, base image, and build tools) to ensure `serialport` compiles correctly?

Any insights or proven solutions would be highly appreciated. Thank you!

---

<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: [16 July 2025 05:23 UTC](https://discourse.nodered.org/t/struggling-to-install-node-red-contrib-modbus-on-raspberry-pi-4-debian-docker-compose-gyp-undefined-variable-error/98158/2 "2025-07-16T05:23:47Z")

</div>

> [@maciejbilu](#):
>
> Python 2 Confirmed

What is the reason for using python 2 ?

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)
#### Post date: [14 October 2025 05:24 UTC](https://discourse.nodered.org/t/struggling-to-install-node-red-contrib-modbus-on-raspberry-pi-4-debian-docker-compose-gyp-undefined-variable-error/98158/3 "2025-10-14T05:24:34Z")

</div>

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