Just going back to the basics here, the installation of node-red-contrib-modbus
fails, so have tried installing serialport
both ‘by hand’ on the terminal and also through the dockerfile (npm install serialport
).
Logs for reference:
19.11.18 09:58:26 (+0000) main 19 Nov 09:58:26 - [info] Installing module: node-red-contrib-modbus, version: 4.1.1
19.11.18 10:00:32 (+0000) main 19 Nov 10:00:32 - [warn] Installation of module node-red-contrib-modbus failed:
19.11.18 10:00:32 (+0000) main 19 Nov 10:00:32 - [warn] ------------------------------------------
19.11.18 10:00:32 (+0000) main 19 Nov 10:00:32 - [warn]
19.11.18 10:00:32 (+0000) main > @serialport/bindings@2.0.2 install /data/node-red/user/node_modules/@serialport/bindings
19.11.18 10:00:32 (+0000) main > prebuild-install --tag-prefix @serialport/bindings@ || node-gyp rebuild
19.11.18 10:00:32 (+0000) main
19.11.18 10:00:32 (+0000) main prebuild-install WARN install No prebuilt binaries found (target=6.14.4 runtime=node arch=arm platform=linux)
19.11.18 10:00:32 (+0000) main make: Entering directory '/data/node-red/user/node_modules/@serialport/bindings/build'
19.11.18 10:00:32 (+0000) main CXX(target) Release/obj.target/bindings/src/serialport.o
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp: In function 'void EIO_AfterOpen(uv_work_t*)':
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp:95:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
19.11.18 10:00:32 (+0000) main data->callback.Call(2, argv);
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main In file included from ../src/./serialport.h:6:0,
19.11.18 10:00:32 (+0000) main from ../src/serialport.cpp:1:
19.11.18 10:00:32 (+0000) main ../../../nan/nan.h:1655:3: note: declared here
19.11.18 10:00:32 (+0000) main Call(int argc, v8::Local<v8::Value> argv[]) const {
19.11.18 10:00:32 (+0000) main ^~~~
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp: In function 'void EIO_AfterUpdate(uv_work_t*)':
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp:150:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
19.11.18 10:00:32 (+0000) main data->callback.Call(1, argv);
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main In file included from ../src/./serialport.h:6:0,
19.11.18 10:00:32 (+0000) main from ../src/serialport.cpp:1:
19.11.18 10:00:32 (+0000) main ../../../nan/nan.h:1655:3: note: declared here
19.11.18 10:00:32 (+0000) main Call(int argc, v8::Local<v8::Value> argv[]) const {
19.11.18 10:00:32 (+0000) main ^~~~
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp: In function 'void EIO_AfterClose(uv_work_t*)':
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp:188:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
19.11.18 10:00:32 (+0000) main data->callback.Call(1, argv);
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main In file included from ../src/./serialport.h:6:0,
19.11.18 10:00:32 (+0000) main from ../src/serialport.cpp:1:
19.11.18 10:00:32 (+0000) main ../../../nan/nan.h:1655:3: note: declared here
19.11.18 10:00:32 (+0000) main Call(int argc, v8::Local<v8::Value> argv[]) const {
19.11.18 10:00:32 (+0000) main ^~~~
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp: In function 'void EIO_AfterFlush(uv_work_t*)':
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp:231:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
19.11.18 10:00:32 (+0000) main data->callback.Call(1, argv);
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main In file included from ../src/./serialport.h:6:0,
19.11.18 10:00:32 (+0000) main from ../src/serialport.cpp:1:
19.11.18 10:00:32 (+0000) main ../../../nan/nan.h:1655:3: note: declared here
19.11.18 10:00:32 (+0000) main Call(int argc, v8::Local<v8::Value> argv[]) const {
19.11.18 10:00:32 (+0000) main ^~~~
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp: In function 'void EIO_AfterSet(uv_work_t*)':
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp:285:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
19.11.18 10:00:32 (+0000) main data->callback.Call(1, argv);
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main In file included from ../src/./serialport.h:6:0,
19.11.18 10:00:32 (+0000) main from ../src/serialport.cpp:1:
19.11.18 10:00:32 (+0000) main ../../../nan/nan.h:1655:3: note: declared here
19.11.18 10:00:32 (+0000) main Call(int argc, v8::Local<v8::Value> argv[]) const {
19.11.18 10:00:32 (+0000) main ^~~~
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp: In function 'void EIO_AfterGet(uv_work_t*)':
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp:336:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
19.11.18 10:00:32 (+0000) main data->callback.Call(2, argv);
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main In file included from ../src/./serialport.h:6:0,
19.11.18 10:00:32 (+0000) main from ../src/serialport.cpp:1:
19.11.18 10:00:32 (+0000) main ../../../nan/nan.h:1655:3: note: declared here
19.11.18 10:00:32 (+0000) main Call(int argc, v8::Local<v8::Value> argv[]) const {
19.11.18 10:00:32 (+0000) main ^~~~
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp: In function 'void EIO_AfterGetBaudRate(uv_work_t*)':
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp:383:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
19.11.18 10:00:32 (+0000) main data->callback.Call(2, argv);
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main In file included from ../src/./serialport.h:6:0,
19.11.18 10:00:32 (+0000) main from ../src/serialport.cpp:1:
19.11.18 10:00:32 (+0000) main ../../../nan/nan.h:1655:3: note: declared here
19.11.18 10:00:32 (+0000) main Call(int argc, v8::Local<v8::Value> argv[]) const {
19.11.18 10:00:32 (+0000) main ^~~~
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp: In function 'void EIO_AfterDrain(uv_work_t*)':
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp:424:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
19.11.18 10:00:32 (+0000) main data->callback.Call(1, argv);
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main In file included from ../src/./serialport.h:6:0,
19.11.18 10:00:32 (+0000) main from ../src/serialport.cpp:1:
19.11.18 10:00:32 (+0000) main ../../../nan/nan.h:1655:3: note: declared here
19.11.18 10:00:32 (+0000) main Call(int argc, v8::Local<v8::Value> argv[]) const {
19.11.18 10:00:32 (+0000) main ^~~~
19.11.18 10:00:32 (+0000) main CXX(target) Release/obj.target/bindings/src/serialport_unix.o
19.11.18 10:00:32 (+0000) main ../src/serialport_unix.cpp:24:26: fatal error: linux/serial.h: No such file or directory
19.11.18 10:00:32 (+0000) main #include <linux/serial.h>
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main compilation terminated.
19.11.18 10:00:32 (+0000) main make: *** [bindings.target.mk:95: Release/obj.target/bindings/src/serialport_unix.o] Error 1
19.11.18 10:00:32 (+0000) main make: Leaving directory '/data/node-red/user/node_modules/@serialport/bindings/build'
19.11.18 10:00:32 (+0000) main gyp ERR! build error
19.11.18 10:00:32 (+0000) main gyp ERR! stack Error: `make` failed with exit code: 2
19.11.18 10:00:32 (+0000) main gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
19.11.18 10:00:38 (+0000) Warning: Suppressed 13 message(s) due to slow reading
19.11.18 10:00:32 (+0000) main prebuild-install WARN install No prebuilt binaries found (target=6.14.4 runtime=node arch=arm platform=linux)
19.11.18 10:00:32 (+0000) main make: Entering directory '/data/node-red/user/node_modules/node-red-contrib-modbus/node_modules/modbus-serial/node_modules/serialport/build'
19.11.18 10:00:32 (+0000) main CXX(target) Release/obj.target/serialport/src/serialport.o
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp: In function 'void EIO_AfterOpen(uv_work_t*)':
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp:95:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
19.11.18 10:00:32 (+0000) main data->callback.Call(2, argv);
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main In file included from ../src/./serialport.h:6:0,
19.11.18 10:00:32 (+0000) main from ../src/serialport.cpp:1:
19.11.18 10:00:32 (+0000) main ../../../../../../nan/nan.h:1655:3: note: declared here
19.11.18 10:00:32 (+0000) main Call(int argc, v8::Local<v8::Value> argv[]) const {
19.11.18 10:00:32 (+0000) main ^~~~
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp: In function 'void EIO_AfterUpdate(uv_work_t*)':
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp:150:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
19.11.18 10:00:32 (+0000) main data->callback.Call(1, argv);
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main In file included from ../src/./serialport.h:6:0,
19.11.18 10:00:32 (+0000) main from ../src/serialport.cpp:1:
19.11.18 10:00:32 (+0000) main ../../../../../../nan/nan.h:1655:3: note: declared here
19.11.18 10:00:32 (+0000) main Call(int argc, v8::Local<v8::Value> argv[]) const {
19.11.18 10:00:32 (+0000) main ^~~~
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp: In function 'void EIO_AfterClose(uv_work_t*)':
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp:188:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
19.11.18 10:00:32 (+0000) main data->callback.Call(1, argv);
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main In file included from ../src/./serialport.h:6:0,
19.11.18 10:00:32 (+0000) main from ../src/serialport.cpp:1:
19.11.18 10:00:32 (+0000) main ../../../../../../nan/nan.h:1655:3: note: declared here
19.11.18 10:00:32 (+0000) main Call(int argc, v8::Local<v8::Value> argv[]) const {
19.11.18 10:00:32 (+0000) main ^~~~
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp: In function 'void EIO_AfterFlush(uv_work_t*)':
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp:231:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
19.11.18 10:00:32 (+0000) main data->callback.Call(1, argv);
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main In file included from ../src/./serialport.h:6:0,
19.11.18 10:00:32 (+0000) main from ../src/serialport.cpp:1:
19.11.18 10:00:32 (+0000) main ../../../../../../nan/nan.h:1655:3: note: declared here
19.11.18 10:00:32 (+0000) main Call(int argc, v8::Local<v8::Value> argv[]) const {
19.11.18 10:00:32 (+0000) main ^~~~
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp: In function 'void EIO_AfterSet(uv_work_t*)':
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp:285:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
19.11.18 10:00:32 (+0000) main data->callback.Call(1, argv);
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main In file included from ../src/./serialport.h:6:0,
19.11.18 10:00:32 (+0000) main from ../src/serialport.cpp:1:
19.11.18 10:00:32 (+0000) main ../../../../../../nan/nan.h:1655:3: note: declared here
19.11.18 10:00:32 (+0000) main Call(int argc, v8::Local<v8::Value> argv[]) const {
19.11.18 10:00:32 (+0000) main ^~~~
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp: In function 'void EIO_AfterGet(uv_work_t*)':
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp:336:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
19.11.18 10:00:32 (+0000) main data->callback.Call(2, argv);
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main In file included from ../src/./serialport.h:6:0,
19.11.18 10:00:32 (+0000) main from ../src/serialport.cpp:1:
19.11.18 10:00:32 (+0000) main ../../../../../../nan/nan.h:1655:3: note: declared here
19.11.18 10:00:32 (+0000) main Call(int argc, v8::Local<v8::Value> argv[]) const {
19.11.18 10:00:32 (+0000) main ^~~~
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp: In function 'void EIO_AfterGetBaudRate(uv_work_t*)':
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp:383:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
19.11.18 10:00:32 (+0000) main data->callback.Call(2, argv);
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main In file included from ../src/./serialport.h:6:0,
19.11.18 10:00:32 (+0000) main from ../src/serialport.cpp:1:
19.11.18 10:00:32 (+0000) main ../../../../../../nan/nan.h:1655:3: note: declared here
19.11.18 10:00:32 (+0000) main Call(int argc, v8::Local<v8::Value> argv[]) const {
19.11.18 10:00:32 (+0000) main ^~~~
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp: In function 'void EIO_AfterDrain(uv_work_t*)':
19.11.18 10:00:32 (+0000) main ../src/serialport.cpp:424:30: warning: 'v8::Local<v8::Value> Nan::Callback::Call(int, v8::Local<v8::Value>*) const' is deprecated [-Wdeprecated-declarations]
19.11.18 10:00:32 (+0000) main data->callback.Call(1, argv);
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main In file included from ../src/./serialport.h:6:0,
19.11.18 10:00:32 (+0000) main from ../src/serialport.cpp:1:
19.11.18 10:00:32 (+0000) main ../../../../../../nan/nan.h:1655:3: note: declared here
19.11.18 10:00:32 (+0000) main Call(int argc, v8::Local<v8::Value> argv[]) const {
19.11.18 10:00:32 (+0000) main ^~~~
19.11.18 10:00:32 (+0000) main CXX(target) Release/obj.target/serialport/src/serialport_unix.o
19.11.18 10:00:32 (+0000) main ../src/serialport_unix.cpp:24:26: fatal error: linux/serial.h: No such file or directory
19.11.18 10:00:32 (+0000) main #include <linux/serial.h>
19.11.18 10:00:32 (+0000) main ^
19.11.18 10:00:32 (+0000) main compilation terminated.
19.11.18 10:00:32 (+0000) main make: *** [serialport.target.mk:95: Release/obj.target/serialport/src/serialport_unix.o] Error 1
19.11.18 10:00:32 (+0000) main make: Leaving directory '/data/node-red/user/node_modules/node-red-contrib-modbus/node_modules/modbus-serial/node_modules/serialport/build'
19.11.18 10:00:32 (+0000) main gyp ERR! build error
19.11.18 10:00:32 (+0000) main gyp ERR! stack Error: `make` failed with exit code: 2
19.11.18 10:00:32 (+0000) main gyp ERR! stack at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:276:23)
19.11.18 10:00:32 (+0000) main gyp ERR! stack at emitTwo (events.js:106:13)
19.11.18 10:00:32 (+0000) main gyp ERR! stack at ChildProcess.emit (events.js:191:7)
19.11.18 10:00:32 (+0000) main gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:219:12)
19.11.18 10:00:32 (+0000) main gyp ERR! System Linux 4.14.68
UPDATE:
Looks like I’ve sorted it! Apologies for the many posts, but I hope this serves useful for others in the future. I was reading through https://serialport.io/docs/en/guide-installation and noticed the ‘installation for Alpine Linux’ section. I added the build commands to my dockerfile and all works good now! You need to remove the sudos
mind
This is what this part of my dockerfile looks like now:
RUN apk add --no-cache make gcc g++ python py-pip python-dev && \
pip install rpi.gpio && \
apk add --no-cache nodejs && \
apk add --no-cache make gcc g++ python linux-headers udev && \
npm install serialport --build-from-source --unsafe-perm && \
JOBS=MAX npm install -g node-red node-red-contrib-resinio --production --silent