Repository navigation
Latest docker build breaks node-gyp in node-18 #2009
Description
Activity
Is it somehow missing python from the install?
We had the latest node:18-alpine image (now pointing to node:18-alpine3.19 instead of node:18-alpine3.18) segfault and had to hardcode not to use the 18-alpine tag but specifically the alpine3.18 based one.
Maybe related?
I can't be very specific publicly, but two of our use cases using the alpine3.19 based node:18 image always exited with
exit code: 139Had same issues with Sharp too, maybe some compilation libraries (libc, musl) are outdated or updated?
#0 61.63 npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] #0 61.63 npm ERR! ../src/pipeline.cc: In member function 'virtual void PipelineWorker::OnOK()': #0 61.63 npm ERR! ../src/pipeline.cc:1229:30: error: aggregate 'PipelineWorker::OnOK()::stat64 st' has incomplete type and cannot be defined #0 61.63 npm ERR! 1229 | struct STAT64_STRUCT st; #0 61.63 npm ERR! | ^~ #0 61.63 npm ERR! ../src/pipeline.cc:1230:55: error: invalid use of incomplete type 'struct PipelineWorker::OnOK()::stat64' #0 61.63 npm ERR! 1230 | if (STAT64_FUNCTION(baton->fileOut.data(), &st) == 0) { #0 61.63 npm ERR! | ^ #0 61.63 npm ERR! ../src/pipeline.cc:44:23: note: forward declaration of 'struct PipelineWorker::OnOK()::stat64' #0 61.63 npm ERR! 44 | #define STAT64_STRUCT stat64 #0 61.63 npm ERR! | ^~~~~~ #0 61.63 npm ERR! ../src/pipeline.cc:1229:16: note: in expansion of macro 'STAT64_STRUCT' #0 61.63 npm ERR! 1229 | struct STAT64_STRUCT st; #0 61.63 npm ERR! | ^~~~~~~~~~~~~ #0 61.63 npm ERR! make: *** [sharp-linuxmusl-x64.target.mk:167: Release/obj.target/sharp-linuxmusl-x64/src/pipeline.o] Error 1Is there any version I can downgrade for now? I can't get the specific tag, but it seems to be this digest which was working for me:
4bdb3f3105718f0742bc8d64bb4e36e8f955ebbee295325e40ae80bc8ef78833Had same issues with Sharp too, maybe some compilation libraries (libc, musl) are outdated or updated?
#0 61.63 npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ] #0 61.63 npm ERR! ../src/pipeline.cc: In member function 'virtual void PipelineWorker::OnOK()': #0 61.63 npm ERR! ../src/pipeline.cc:1229:30: error: aggregate 'PipelineWorker::OnOK()::stat64 st' has incomplete type and cannot be defined #0 61.63 npm ERR! 1229 | struct STAT64_STRUCT st; #0 61.63 npm ERR! | ^~ #0 61.63 npm ERR! ../src/pipeline.cc:1230:55: error: invalid use of incomplete type 'struct PipelineWorker::OnOK()::stat64' #0 61.63 npm ERR! 1230 | if (STAT64_FUNCTION(baton->fileOut.data(), &st) == 0) { #0 61.63 npm ERR! | ^ #0 61.63 npm ERR! ../src/pipeline.cc:44:23: note: forward declaration of 'struct PipelineWorker::OnOK()::stat64' #0 61.63 npm ERR! 44 | #define STAT64_STRUCT stat64 #0 61.63 npm ERR! | ^~~~~~ #0 61.63 npm ERR! ../src/pipeline.cc:1229:16: note: in expansion of macro 'STAT64_STRUCT' #0 61.63 npm ERR! 1229 | struct STAT64_STRUCT st; #0 61.63 npm ERR! | ^~~~~~~~~~~~~ #0 61.63 npm ERR! make: *** [sharp-linuxmusl-x64.target.mk:167: Release/obj.target/sharp-linuxmusl-x64/src/pipeline.o] Error 1Is there any version I can downgrade for now? I can't get the specific tag, but it seems to be this digest which was working for me:
4bdb3f3105718f0742bc8d64bb4e36e8f955ebbee295325e40ae80bc8ef78833I downgraded to
node:18-alpine3.18and everything is work for now, I'll continue to follow this issue to upgrade when I canReacted by Allan C, Christian Meter, Héliton Oliveira and Nate ReynoldsReacted by Allan C, Christian Meter, Héliton Oliveira, Nate Reynolds, doandroidsdreamof and Karl LettenströmAh, for some, this looks like a sharp module incompatibility with the newer
libvipsof the Alpine packages. In Alpine 3.18,libvipsis8.13.3, but it is8.15.0in Alpine 3.19 (https://pkgs.alpinelinux.org/packages?name=vips-dev&branch=v3.19).https://github.com/lovell/sharp/blob/v0.30.7/package.json#L157
https://github.com/lovell/sharp/blob/v0.31.3/package.json#L158
https://github.com/lovell/sharp/blob/v0.32.6/package.json#L162
https://github.com/lovell/sharp/blob/v0.33.0/package.json#L190I think just updating your sharp dependency should be enough in some cases:
$ docker run --rm node:18-alpine3.19 npm install -g sharp@0.30 npm ERR! code 1 npm ERR! path /usr/local/lib/node_modules/sharp npm ERR! command failed npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy) npm ERR! sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies npm ERR! sharp: Installation error: Invalid Version: 1.2.4_git20230717 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2023-12-13T19_14_03_677Z-debug-0.log $ docker run --rm node:18-alpine3.19 npm install -g sharp@0.31 npm ERR! code 1 npm ERR! path /usr/local/lib/node_modules/sharp npm ERR! command failed npm ERR! command sh -c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy) npm ERR! sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies npm ERR! sharp: Installation error: Invalid Version: 1.2.4_git20230717 npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2023-12-13T19_14_11_327Z-debug-0.log $ docker run --rm node:18-alpine3.19 npm install -g sharp@0.32 added 51 packages in 3s $ docker run --rm node:18-alpine3.19 npm install -g sharp@0.33 added 15 packages in 2s
Reacted by Liam Rathke, Johnson Liang, Apurba Behera, Gareth Gomersall, david-loe, Helton Fábio and Fredrik BoströmI confirm the problem using node:18-alpine3.19
Running
npm ithis is the problem shown:npm ERR! code 1 npm ERR! path /usr/src/app/node_modules/sharp npm ERR! command failed npm ERR! sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies npm ERR! sharp: Installation error: Invalid Version: 1.2.4_git20230717
Downgrade to node:18-alpine3.18 it works.
Reacted by Jurijs I, Dirk Fröhling, Aleksandr-Zharkov, Shavkat Kasymov, Paul, Giovanni Bamou, fenghan34, Héliton Oliveira, SametSahin10, BR1%ers and 2 moreReacted by Lee Salminen, asimkprasad, ziudeso, Luan Lima, baguwka, Ahmet Polat, tan.raksit, Michael Devereux, Aleksandr-Zharkov, Shavkat Kasymov and 5 moreReacted by ziudeso, StoCreator, Jordan GIDOIN, Luan Lima, Michal Ruzicka Ruzicka, Matthias Schulz, Aleksandr-Zharkov, Shavkat Kasymov and Héliton OliveiraReacted by Shavkat Kasymov and Héliton OliveiraThis is happening when node and sharp versions mismatch in my case. So I recommend trying to install both node and sharp latest versions. Either try downgrading both node and sharp versions as for your needs. In my case, node 16 and sharp 0.30.3 work fine. But sharp 0.30.3 doesn't work with node 20.
Changing image from
node:18-alpinetonode:18-alpine3.18in myDockerfileworked for me.Reacted by Robert WeißeWhy do I still get an error after changing it to node:18-alpine3.18?
I am using image node:20-alpine3.18 from node:18-alpine works for me..
It works for me also with node:18-alpine3.18. Hopefully, this will be fixed in the next releases.
The Alpine image never supported node-gyp building without additional packages being added. Instructions can be found here https://github.com/nodejs/docker-node/blob/main/docs/BestPractices.md#node-gyp-alpine
Likely the Sharp or other packages were shipping pre-built binaries that aren't currently compatible with the newest Alpine image, no change in this repo will fix that.Reacted by yar2001, Marcin Trofimiuk and Juk - Chukkrit V.- added a commit that references this issue
on Dec 28, 2023 - added a commit that references this issue
on Jan 2, 2024 @nschonni I tried following those instructions using
node:20-alpine, I had the same build error until I switched tonode:20-alpine3.18without those extra apt packages being installed.Reacted by Sujin Park, Yerko Acuña, Kevin Rousseau, Robert Weiße and Helton FábioFor me it worked by changing the alpine version to 3.18.
Dockerfile:
FROM node:18-alpine3.18 AS buildworking on
node:21-alpine3.18Reacted by Luan Lima, Jonas Schneider and Andrei SenaevReacted by Luan Lima- added a commit that references this issue
on Mar 26, 2024 - added a commit that references this issue
on Mar 26, 2024 - added 2 commits that reference this issue
on May 19, 2024 still get the error when I use
node:20-alpine3.18ornode:18-alpine3.18To resolve this, you need to ensure that Python is installed and available in the Docker image. Add the following to your Dockerfile
FROM node:18-alpine # 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/pipThis worked for me.
Reacted by Mario D and Ukpai Chukwuemeka- added a commit that references this issue
on Mar 7, 2025 - added a commit that references this issue
on Mar 7, 2025 - added a commit that references this issue
on Sep 27, 2025
Environment
(This happens inside my managed CI provider, not sure on its version)
Current Behavior
When I install sharp, it fails due to node gyp:
This was working yesterday and seems to coincide with this build going live:
When I stick my docker version to the node:18-alpine3.18 it works again.