Error when installing mozjpeg - mozjpeg/vendor/cjpeg ENOENT

1.7k views Asked by At

I'm trying to install mozjpeg in a Docker container which runs

NAME="Alpine Linux"
ID=alpine
VERSION_ID=3.11.7
PRETTY_NAME="Alpine Linux v3.11"
HOME_URL="https://alpinelinux.org/"
BUG_REPORT_URL="https://bugs.alpinelinux.org/"

And I get the following error

yarn install --frozen-lockfile
yarn install v1.19.2
[1/4] Resolving packages...
[2/4] Fetching packages...
info [email protected]: The platform "linux" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning " > @typescript-eslint/[email protected]" has incorrect peer dependency "eslint@^5.0.0 || ^6.0.0".
warning " > @typescript-eslint/[email protected]" has incorrect peer dependency "eslint@^5.0.0 || ^6.0.0".
warning " > @typescript-eslint/[email protected]" has incorrect peer dependency "eslint@^5.0.0 || ^6.0.0".
warning "serverless > @serverless/components > [email protected]" has unmet peer dependency "inquirer@^5.0.0 || ^6.0.0 || ^7.0.0 || ^8.0.0".
warning " > [email protected]" has incorrect peer dependency "serverless@^2.4.0".
[4/4] Building fresh packages...
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error /builds/conversion-handler/node_modules/mozjpeg: Command failed.
Exit code: 1
Command: node lib/install.js
Arguments: 
Directory: /builds/conversion-handler/node_modules/mozjpeg
Output:
⚠ spawn /builds/conversion-handler/node_modules/mozjpeg/vendor/cjpeg ENOENT
  ⚠ mozjpeg pre-build test failed
  ℹ compiling from source
  ✖ Error: Command failed: /bin/sh -c ./configure --enable-static --disable-shared --disable-dependency-tracking --with-jpeg8  --prefix="/builds/conversion-handler/node_modules/mozjpeg/vendor" --bindir="/builds/conversion-handler/node_modules/mozjpeg/vendor" --libdir="/builds/conversion-handler/node_modules/mozjpeg/vendor"
configure: error: in `/tmp/5165e468-cf39-4de1-843a-506698a12de7':
configure: error: no acceptable C compiler found in $PATH
See `config.log' for more details
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... ./install-sh -c -d
checking for gawk... no
checking for mawk... no
checking for nawk... no
checking for awk... awk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking whether make supports nested variables... (cached) yes
checking whether make supports the include directive... yes (GNU style)
checking for gcc... no
checking for cc... no
checking for cl.exe... no
    at /builds/conversion-handler/node_modules/execa/index.js:231:11
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Promise.all (index 0)

I tried running - apk add automake autoconf libtool dpkg pkgconfig nasm libpng before calling yarn install but that did not help.

Please advise how can I resolve this?

1

There are 1 answers

0
TeNNoX On

Some additional packages are needed:

apk add --no-cache build-base git python util-linux \
  vips-dev autoconf libtool dpkg pkgconfig nasm \
  libpng autoconf automake libtool tiff jpeg \
  zlib zlib-dev pkgconf nasm file

I got some of them from the comment here, I did not test which ones are not needed. ;)