Node-Gyp Error Docker React App

Hey y'all, I'm trying to build a react app but I'm not able to install node-gyp for some reason. I saw there's responses about using Nix, but I'd rather use Docker. I've tried a bunch of different apk scripts but still no luck. I've also tried using different node versions, any ideas? Dockerfile:
FROM node:lts-alpine3.17 AS builder

# Install dependencies including Python
RUN apk add --no-cache python3 py3-pip make g++ \
&& ln -sf python3 /usr/bin/python \
&& ln -sf pip3 /usr/bin/pip

# set the working directory
WORKDIR /app

# copy the package.json and package-lock.json files
COPY package.json .
COPY package-lock.json .

# install the dependencies
RUN npm ci

# copy the rest of the files
COPY . .

# build the app
RUN npm run build

# set the command to run the app
CMD ["npm", "run", "start"]
FROM node:lts-alpine3.17 AS builder

# Install dependencies including Python
RUN apk add --no-cache python3 py3-pip make g++ \
&& ln -sf python3 /usr/bin/python \
&& ln -sf pip3 /usr/bin/pip

# set the working directory
WORKDIR /app

# copy the package.json and package-lock.json files
COPY package.json .
COPY package-lock.json .

# install the dependencies
RUN npm ci

# copy the rest of the files
COPY . .

# build the app
RUN npm run build

# set the command to run the app
CMD ["npm", "run", "start"]
Error
#10 44.93 npm ERR! code 1

#10 44.93 npm ERR! path /app/node_modules/usb

#10 44.93 npm ERR! command failed

#10 44.93 npm ERR! command sh -c node-gyp-build

#10 44.93 npm ERR! make: Entering directory '/app/node_modules/usb/build'

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/core.o

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/descriptor.o

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/hotplug.o

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/io.o

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/strerror.o

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/sync.o

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/os/events_posix.o

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/os/threads_posix.o

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/os/linux_usbfs.o

#10 44.94 npm ERR! make: Leaving directory '/app/node_modules/usb/build'

#10 44.94 npm ERR! gyp info it worked if it ends with ok

#10 44.94 npm ERR! gyp info using [email protected]

#10 44.94 npm ERR! gyp info using [email protected] | linux | x64

#10 44.94 npm ERR! gyp info find Python using Python version 3.10.15 found at "/usr/bin/python3"

#10 44.94 npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v20.10.0/node-v20.10.0-headers.tar.gz

#10 44.94 npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v20.10.0/node-v20.10.0-headers.tar.gz

#10 44.94 npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v20.10.0/SHASUMS256.txt

#10 44.94 npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v20.10.0/SHASUMS256.txt
#10 44.93 npm ERR! code 1

#10 44.93 npm ERR! path /app/node_modules/usb

#10 44.93 npm ERR! command failed

#10 44.93 npm ERR! command sh -c node-gyp-build

#10 44.93 npm ERR! make: Entering directory '/app/node_modules/usb/build'

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/core.o

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/descriptor.o

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/hotplug.o

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/io.o

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/strerror.o

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/sync.o

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/os/events_posix.o

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/os/threads_posix.o

#10 44.93 npm ERR! CC(target) Release/obj.target/libusb/libusb/libusb/os/linux_usbfs.o

#10 44.94 npm ERR! make: Leaving directory '/app/node_modules/usb/build'

#10 44.94 npm ERR! gyp info it worked if it ends with ok

#10 44.94 npm ERR! gyp info using [email protected]

#10 44.94 npm ERR! gyp info using [email protected] | linux | x64

#10 44.94 npm ERR! gyp info find Python using Python version 3.10.15 found at "/usr/bin/python3"

#10 44.94 npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v20.10.0/node-v20.10.0-headers.tar.gz

#10 44.94 npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v20.10.0/node-v20.10.0-headers.tar.gz

#10 44.94 npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v20.10.0/SHASUMS256.txt

#10 44.94 npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v20.10.0/SHASUMS256.txt
Solution:
I was able to build it using a full image, as the alpine builds are lightweight: https://github.com/nodejs/docker-node/issues/384 It's a workaround but still curious how I'd do this manually through an alpine image...
GitHub
node:7.9-alpine unable to build package due python is not installed...
Latest solution #384 (comment) Edit 2017: check this solution #384 (comment) Edit 2021: check this solution #384 (comment) Edit 2021: check note on required dependencies: #384 (comment) and #384 (c...
Jump to solution
12 Replies
Percy
Percy4w ago
Project ID: 219a95c7-c16f-4dfc-8a87-a950c3537c97
rhh4x0R
rhh4x0ROP4w ago
219a95c7-c16f-4dfc-8a87-a950c3537c97
Solution
rhh4x0R
rhh4x0R4w ago
I was able to build it using a full image, as the alpine builds are lightweight: https://github.com/nodejs/docker-node/issues/384 It's a workaround but still curious how I'd do this manually through an alpine image
GitHub
node:7.9-alpine unable to build package due python is not installed...
Latest solution #384 (comment) Edit 2017: check this solution #384 (comment) Edit 2021: check this solution #384 (comment) Edit 2021: check note on required dependencies: #384 (comment) and #384 (c...
Brody
Brody4w ago
why does the react app need node-gyp?
rhh4x0R
rhh4x0ROP4w ago
Looks like it's coming from a solana wallet adapter, web3 shit.
Brody
Brody4w ago
what is your start script?
rhh4x0R
rhh4x0ROP4w ago
NODE_ENV=production node out/index.js
Brody
Brody4w ago
is this some kind of express / frontend jumble?
rhh4x0R
rhh4x0ROP4w ago
Yep. It's building fine with just the regular node:20.17 image instead of alpine.
Brody
Brody4w ago
then that seens like a good solution, we don't charge for build or image storage
rhh4x0R
rhh4x0ROP4w ago
So, I just got it deployed and works great now. Ok got it, thanks.
Brody
Brody4w ago
no problem!
Want results from more Discord servers?
Add your server