Node-Gyp Error Docker React App
rhh4x0r
PROOP

a year ago

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"]

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 node-gyp@10.2.0

#10 44.94 npm ERR! gyp info using node@20.10.0 | 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

13 Replies

rhh4x0r
PROOP

a year ago

219a95c7-c16f-4dfc-8a87-a950c3537c97


rhh4x0r
PROOP

a year 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


a year ago

why does the react app need node-gyp?


rhh4x0r
PROOP

a year ago

Looks like it's coming from a solana wallet adapter, web3 shit.


a year ago

what is your start script?


rhh4x0r
PROOP

a year ago

NODE_ENV=production node out/index.js


a year ago

is this some kind of express / frontend jumble?


rhh4x0r
PROOP

a year ago

Yep.


rhh4x0r
PROOP

a year ago

It's building fine with just the regular node:20.17 image instead of alpine.


a year ago

then that seens like a good solution, we don't charge for build or image storage


rhh4x0r
PROOP

a year ago

So, I just got it deployed and works great now.


rhh4x0r
PROOP

a year ago

Ok got it, thanks.


a year ago

no prblem!


Loading...