Install / Run Zwave in Node Red Docker Image (on RPi)

Hi all

I try to implement Node-Red for my home automatisation.
Node-Red runs in Docker on my Raspberry Pi. This works without any problems.

But I need Zwave for my Fibaro Motion Sensors.
And I can not install node-red-contrib-openzwave. It failes, because openzwave library and openzwave-shared are not installed in the Docker-Image.

But installation of these dependencies failed each time (in Docker):

pm info it worked if it ends with ok
npm info using npm@5.0.3
npm info using node@v8.1.3
npm http fetch GET 304 517ms (from cache)
npm http fetch GET 304 131ms (from cache)
npm info lifecycle openzwave-shared@1.5.6~preinstall: openzwave-shared@1.5.6
npm info lifecycle nan@2.14.0~preinstall: nan@2.14.0

> openzwave-shared@1.5.6 preinstall /usr/src/node-red/node_modules/openzwave-shared
> node lib/install-ozw.js

npm info linkStuff openzwave-shared@1.5.6
npm info linkStuff nan@2.14.0
npm info lifecycle openzwave-shared@1.5.6~install: openzwave-shared@1.5.6

> openzwave-shared@1.5.6 install /usr/src/node-red/node_modules/openzwave-shared
> node-gyp rebuild

gyp info it worked if it ends with ok
gyp info using node-gyp@3.6.2
gyp info using node@8.1.3 | linux | arm
gyp info spawn /usr/bin/python2
gyp info spawn args [ '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/',
gyp info spawn args   'binding.gyp',
gyp info spawn args   '-f',
gyp info spawn args   'make',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/src/node-red/node_modules/openzwave-shared/build/config.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args   '-I',
gyp info spawn args   '/usr/src/node-red/.node-gyp/8.1.3/include/node/common.gypi',
gyp info spawn args   '-Dlibrary=shared_library',
gyp info spawn args   '-Dvisibility=default',
gyp info spawn args   '-Dnode_root_dir=/usr/src/node-red/.node-gyp/8.1.3',
gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
gyp info spawn args   '-Dnode_lib_file=/usr/src/node-red/.node-gyp/8.1.3/<(target_arch)/node.lib',
gyp info spawn args   '-Dmodule_root_dir=/usr/src/node-red/node_modules/openzwave-shared',
gyp info spawn args   '-Dnode_engine=v8',
gyp info spawn args   '--depth=.',
gyp info spawn args   '--no-parallel',
gyp info spawn args   '--generator-output',
gyp info spawn args   'build',
gyp info spawn args   '-Goutput_dir=.' ]
grep: /usr/*/include/value_classes: No such file or directory
gyp: Call to 'grep -r GetTypeNameFromEnum /usr/*/include/value_classes | wc -l' returned exit status 0 while in binding.gyp. while trying to load binding.gyp
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:336:16)
gyp ERR! stack     at emitTwo (events.js:125:13)
gyp ERR! stack     at ChildProcess.emit (events.js:213:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:197:12)
gyp ERR! System Linux 4.14.97-v7+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/src/node-red/node_modules/openzwave-shared
gyp ERR! node -v v8.1.3
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm info lifecycle openzwave-shared@1.5.6~install: Failed to exec install script
npm ERR! errno 1
npm ERR! openzwave-shared@1.5.6 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the openzwave-shared@1.5.6 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!     /usr/src/node-red/.npm/_logs/2019-07-17T19_47_45_676Z-debug.log

How can I install the dependencies for node-red-contrib-openzwave?

If I start install with 'sudo', it asks for node-red password. How can I set / activate node-red password?
Do I have to change AdminAuth parameter in settings.js?

Does someone installed node-red-contrib-openzwave in docker-env?

Thanks for your inputs.

Do you need to use docker? It makes life a lot more complex and I am not aware of any great advantage on a pi.

not necessarily.
But I wanted to do the tests with Docker and Docker would be my target.

But somehow it should be possible to add the Node Red password. Maybe that will help.

you probably need to custom build your docker container with the extra libraries or build tools in - start with a copy of the node-red dockerfile and go from there.

Of course,... you're right. I didn't think about that.
I will try.

Running "native" node-red makes it all much easier.

I solved the first few issues. I installed prerequisits via
docker exec -it -u root node-red /bin/bash

openzwave-shared I installed also.

But after install 'node-red-contrib-openzwave' (directly in node-red), my node-red docker instance was broken.

npm ERR! Failed at the node-red-docker@1.0.0 start script 'node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"'.,
npm ERR! This is most likely a problem with the node-red-docker package,,
npm ERR! not with npm itself.,
npm ERR! Tell the author that this fails on your system:,
npm ERR!     node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data",
npm ERR! You can get their info via:,
npm ERR!     npm owner ls node-red-docker,
npm ERR! There is likely additional logging output above.,
npm ERR! Please include the following file with any support request:,
npm ERR!     /usr/src/node-red/npm-debug.log,
npm info it worked if it ends with ok,
npm info using npm@2.14.7,
m info using node@v4.2.1,
npm info prestart node-red-docker@1.0.0,
npm info start node-red-docker@1.0.0,
> node-red-docker@1.0.0 start /usr/src/node-red,
> node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data",
exports.write = function (fd, buffer, ...args) {,
SyntaxError: Unexpected token ...,
    at exports.runInThisContext (vm.js:53:16),
    at Module._compile (module.js:414:25),
    at Object.Module._extensions..js (module.js:442:10),
    at Module.load (module.js:356:32),
    at Function.Module._load (module.js:311:12),
    at Module.require (module.js:366:17),
    at require (module.js:385:17),
    at Object.<anonymous> (/usr/src/node-red/node_modules/fs-extra/lib/index.js:6:3),
    at Module._compile (module.js:435:26),
    at Object.Module._extensions..js (module.js:442:10),
npm info node-red-docker@1.0.0 Failed to exec start script,
m ERR! Linux 4.14.97-v7+,
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "start" "--" "--userDir" "/data",
npm ERR! node v4.2.1,
npm ERR! npm  v2.14.7,
npm ERR! node-red-docker@1.0.0 start: `node $NODE_OPTIONS node_modules/node-red/red.js -v $FLOWS "--userDir" "/data"`,
npm ERR! Exit status 1,,

anyone an idea?
@bakman2: Yes, I suppose so too. :wink: But I would like to use Docker - at least for tests.

Is this the version of node you’re using?
node v4.2.1
If so please be aware that current versions of Node-RED require v8.5 or higher as minimum. The LTS releases are supported.

This specific error is caused by a syntax introduced in newer JavaScript versions, this one first supported in ES6, and coincidentally NodeJS 6.0.0 as well. It’s the rest parameters syntax for function arguments.

SyntaxError: Unexpected token ...,

this is node-version on my raspberry pi.
is this the issue on building a own docker image?

which node / npm version should it be on the raspi?

it seems it's realy much easier to install native instead of docker image.:wink:
I know which components are needed, but on every build it crashes. I just do some tests. If failed I change to a native installation.

if it's the version on your pi, rather than inside your container, somehow your setup is using the wrong node. I didn't know docker containers were able to use locally installed software on the host machine. Sounds like a sandboxing issue to be honest. So I guess something is going wrong on that pi, if the wrong node is used. Because looking at the output it suggests that this is the Node version inside the container.

What command were you using to get that output, and can you post your Dockerfile?

from Portainer: Container log

here is my dockerfile

FROM hypriot/rpi-node:${NODE_VERSION}

# add support for gpio library
RUN apt-get update
RUN apt-get install python-rpi.gpio

# install prerequisits for openzwave
RUN apt-get update \
  && apt-get install -y --no-install-recommends \
    libkrb5-dev \
    libudev-dev \
    libudev0 \
    libzmq3-dev \
  && rm -rf /var/lib/apt/lists/* \
  && apt-get clean

RUN wget "" \
  && wget "" \
  && wget "" \
  && wget "" \
  && dpkg -i *.deb \
  && rm *.deb

# Home directory for Node-RED application source code.
RUN mkdir -p /usr/src/node-red

# User data directory, contains flows, config and nodes.
RUN mkdir /data

WORKDIR /usr/src/node-red

# Add node-red user so we aren't running as root.
RUN useradd --home-dir /usr/src/node-red --no-create-home node-red \
    && chown -R node-red:node-red /data \
    && chown -R node-red:node-red /usr/src/node-red

USER node-red

# package.json contains Node-RED NPM module and node dependencies
COPY package.json /usr/src/node-red/
RUN npm install

# User configuration directory volume

# Environment variable holding file path for flows configuration
ENV FLOWS=flows.json
ENV NODE_PATH=/usr/src/node-red/node_modules:/data/node_modules

CMD ["npm", "start", "--", "--userDir", "/data"]

maybe, the problem is install node_latest_armhf.deb, but I couldn't test today.

If you are new to Node-red, docker and Z-Wave i would suggest to you that this is madness.

Start with a native install of Node-red on your RPI (start with a new SD card so you can experiment) once you have that down and working and your Z wave stuff recognized you can decide if you want to turn that into a docker image.

I would suggest you learn a lot more about docker, pass through USB devices and the like before you start down that track though



I took the .deb apart and I'm pretty sure it is the problem. Do you know why you are using this step for installing? Installing that node_latest_armhf.deb file overwrites the Node.JS version already present in your docker image, which is supposed to be node 8 according to the hypriot image.

The node_latest_armhf.deb got created in 2015 and does in fact install the Node 4.2.1 seen before in the error messages. Here's the control file for Debian packages inside it:

Package: node
Priority: extra
Section: checkinstall
Installed-Size: 34396
Maintainer: <redacted to prevent spam>
Architecture: armhf
Version: 4.2.1-1
Provides: node
Description: node v4.2.1

Date of packaging can be seen as October 18th 2015.

Removing this deb from the list might already solve your issue, but as Craig mentioned before me, start with getting a native install that is completely correct. To get there, document all your steps, then take the basic node-red-docker Dockerfile and abstract your documentation to an install procedure.

Well, I didn't assumed, I'm the first to want to run Node-Red with Zwave and MQTT in a Docker container.
But it seems I am. :wink:

@afelix Thank you for your inputs. I will just check it out.

But for now, I will change to a native installation.

Hi. Have you managed to go back to docker-ized install with custom nodes? Or have you decided to stay with native?

Hi, I changed to native installation. With native installation it runs without any problems.

1 Like