'React Js docker image building error with ERROR [linux/arm64 5/7] RUN npm install --silent. Running on Mac M1

I am creating a React Js docker image to run on multiple architecture when i run the command I get an error. I tried a lot but not successful. I am using Mac M1.

My dockerfile

FROM node:18.1-alpine3.15
# set working directory
WORKDIR /ui

# add `/app/node_modules/.bin` to $PATH
ENV PATH /ui/node_modules/.bin:$PATH

COPY . ./app
RUN cd ./app
#RUN npm run build


# install app dependencies
#COPY package.json ./
#COPY package-lock.json ./
RUN npm install --silent 
COPY --chown=node:node . /ui
RUN npm run build-prod

# add app
#COPY . ./
EXPOSE 80
# start app
CMD ["npm", "start-prod"]

The docker run command " docker buildx build --platform linux/amd64,linux/arm64,linux/arm/v7 -t flight-frontr7:v1 " Out put

[+] Building 16.7s (21/27)                                                                                                                                                  
 => [internal] load .dockerignore                                                                                                                                      0.0s
 => => transferring context: 2B                                                                                                                                        0.0s
 => [internal] load build definition from Dockerfile                                                                                                                   0.0s
 => => transferring dockerfile: 498B                                                                                                                                   0.0s
 => [linux/amd64 internal] load metadata for docker.io/library/node:18.1-alpine3.15                                                                                    0.7s
 => [linux/arm/v7 internal] load metadata for docker.io/library/node:18.1-alpine3.15                                                                                   0.7s
 => [linux/arm64 internal] load metadata for docker.io/library/node:18.1-alpine3.15                                                                                    0.7s
 => [internal] load build context                                                                                                                                      8.9s
 => => transferring context: 151.21MB                                                                                                                                  8.8s
 => [linux/amd64 1/7] FROM docker.io/library/node:18.1-alpine3.15@sha256:f4d6916c5625853e81994b5cb53ad3eb27e5fec9451c579d298fee0c508fe621                              0.0s
 => => resolve docker.io/library/node:18.1-alpine3.15@sha256:f4d6916c5625853e81994b5cb53ad3eb27e5fec9451c579d298fee0c508fe621                                          0.0s
 => [linux/arm/v7 1/7] FROM docker.io/library/node:18.1-alpine3.15@sha256:f4d6916c5625853e81994b5cb53ad3eb27e5fec9451c579d298fee0c508fe621                             0.0s
 => => resolve docker.io/library/node:18.1-alpine3.15@sha256:f4d6916c5625853e81994b5cb53ad3eb27e5fec9451c579d298fee0c508fe621                                          0.0s
 => [linux/arm64 1/7] FROM docker.io/library/node:18.1-alpine3.15@sha256:f4d6916c5625853e81994b5cb53ad3eb27e5fec9451c579d298fee0c508fe621                              0.0s
 => => resolve docker.io/library/node:18.1-alpine3.15@sha256:f4d6916c5625853e81994b5cb53ad3eb27e5fec9451c579d298fee0c508fe621                                          0.0s
 => CACHED [linux/arm/v7 2/7] WORKDIR /ui                                                                                                                              0.0s
 => CACHED [linux/arm64 2/7] WORKDIR /ui                                                                                                                               0.0s
 => [linux/arm64 3/7] COPY . ./app                                                                                                                                     5.7s
 => [linux/arm/v7 3/7] COPY . ./app                                                                                                                                    5.7s
 => CACHED [linux/amd64 2/7] WORKDIR /ui                                                                                                                               0.0s
 => [linux/amd64 3/7] COPY . ./app                                                                                                                                     5.7s
 => [linux/arm/v7 4/7] RUN cd ./app                                                                                                                                    0.7s
 => [linux/amd64 4/7] RUN cd ./app                                                                                                                                     0.7s
 => [linux/arm64 4/7] RUN cd ./app                                                                                                                                     0.7s
 => CANCELED [linux/arm/v7 5/7] RUN npm install --silent                                                                                                               0.7s
 => CANCELED [linux/amd64 5/7] RUN npm install --silent                                                                                                                0.7s
 => ERROR [linux/arm64 5/7] RUN npm install --silent                                                                                                                   0.6s
------
 > [linux/arm64 5/7] RUN npm install --silent:
------
WARNING: No output specified for docker-container driver. Build result will only remain in the build cache. To push result image into registry use --push or to load image into docker use --load
Dockerfile:16
--------------------
  14 |     #COPY package.json ./
  15 |     #COPY package-lock.json ./
  16 | >>> RUN npm install --silent 
  17 |     COPY --chown=node:node . /ui
  18 |     RUN npm run build-prod
--------------------
error: failed to solve: process "/bin/sh -c npm install --silent" did not complete successfully: exit code: 254


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source