Migrating a raspberry pi Nodejs project from pi3 to pi4

I am migrating a Node.js project from a raspberrypi3 to a raspberrypi4. The project has a dependency on rpio. I updated the docker image from:
resin/raspberrypi3-node:8 ==> balenalib/raspberrypi4-64-node:8.

The docker file look like this:

FROM balenalib/raspberrypi4-64-node:8

# use apt-get if you need to install dependencies,
# for instance if you need ALSA sound utils, just uncomment the lines below.
RUN apt-get update && apt-get install -yq \
   alsa-utils libasound2-dev && \
   apt-get clean && rm -rf /var/lib/apt/lists/*

# Set up ALSA config
COPY config/asound.conf /etc/asound.conf

# Defines our working directory in container
WORKDIR /usr/src/app

# Copies the package.json first for better cache on later pushes
COPY package.json package.json
COPY package-lock.json package-lock.json

# This install npm dependencies on the balena build server,
# making sure to clean up the artifacts it creates in order to reduce the image size.
RUN JOBS=MAX npm install --production --unsafe-perm && rm -rf /tmp/*

# This will copy all files in our root to the working  directory in the container
COPY . ./

# Enable systemd init system in container

CMD ["npm", "start"]

But when I try to build this docker image, I get the following error:

Step 7/10 : RUN JOBS=MAX npm install --production --unsafe-perm && rm -rf /tmp/*
 ---> Running in 6d1aaa1e829f
Unknown QEMU_IFLA_INFO_KIND ip6tnl

> grpc@1.24.0 install /usr/src/app/node_modules/grpc
> node-pre-gyp install --fallback-to-build --library=static_library

node-pre-gyp WARN Using request for node-pre-gyp https download 
[grpc] Success: "/usr/src/app/node_modules/grpc/src/node/extension_binary/node-v57-linux-arm64-glibc/grpc_node.node" is installed via remote

> rpio@1.1.0 install /usr/src/app/node_modules/rpio
> node-gyp rebuild

gyp ERR! configure error 
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack     at PythonFinder.failNoPython (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:484:19)
gyp ERR! stack     at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:406:16)
gyp ERR! stack     at F (/usr/local/lib/node_modules/npm/node_modules/which/which.js:68:16)
gyp ERR! stack     at E (/usr/local/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/isexe/index.js:42:5
gyp ERR! stack     at /usr/local/lib/node_modules/npm/node_modules/isexe/mode.js:8:5
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Linux 4.9.184-linuxkit
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/app/node_modules/rpio
gyp ERR! node -v v8.16.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
npm ERR! errno 1
npm ERR! rpio@1.1.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the rpio@1.1.0 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!     /root/.npm/_logs/2019-10-11T13_17_18_111Z-debug.log

Do you have any ideas what this error could be - do I need to include python somehow?

Hello, can you try adding python to the apt-get line?
Something like:

RUN apt-get update && apt-get install -yq \
   alsa-utils libasound2-dev python && \
   apt-get clean && rm -rf /var/lib/apt/lists/*

Hi @zvin - thanks for helping out. I am still in the process of learning Docker. I added python , but now I get a new error: gyp ERR! stack Error: not found: make.

I read the following on the rpio github readme:

Newer versions of node.js require you to install the GCC 4.8 packages for C++11 support. If you see compilation problems related to C++11, this is the likely cause.

I remember having issues with this make thing, when using the raspberry3 image. But back then the conclusion was that the resin/raspberrypi3-node:8 actually included the build-essential toolchain. That is maybe not the case anymore?

I don’t think resin/raspberrypi3-node includeded any build tool, it was just node.
If it did, I guess it was an error as it would make the image quite larger.
You’ll need to add build-essential as well.

Thanks - that did the trick! Now I have to debug an error from rpio, but it seems to build correctly :slight_smile:

You’re welcome :slight_smile: