Reputation: 2406
From yesterday I am unable to deploy my Gatsby site to our server, build is complaining about mozjpeg library. Have anyone encountered this error before?
I tried:
automake
linux packagelibtools
linux packageBut nothing seemed to help, the error is as follows:
error /node_modules/mozjpeg: Command failed.
Exit code: 1
Command: node lib/install.js
Arguments:
Directory: /node_modules/mozjpeg
Output:
⚠ spawn /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="/node_modules/mozjpeg/vendor" --bindir="/node_modules/mozjpeg/vendor" --libdir="/node_modules/mozjpeg/vendor"
OS Ubuntu 16.04.6 Node 12.14 Gatsby 2.19.7
Upvotes: 5
Views: 9042
Reputation: 1
I just went through this same issue on Alpine in a Dockerfile. Turns out that what it needed was everything that you'd typically need to build from source. Alpine has a package called alpine-apk
that I added to the Dockerfile. This fixed all subsequent issues that I had with mozjpeg
. I realize that the original poster isn't running Alpine but I wanted this to get posted somewhere so that another person with this issue has.
Upvotes: -1
Reputation: 19
The same issue arises when deploying to to GitLab pages using the docker image: "node:lts-alpine"
. It fails because yarn:install
cannot build mozjpeg
.
error /builds/my_project/gatsby/node_modules/mozjpeg: Command failed.
To fix it, add these lines to .gitlab-ci.yml
before_script:
- apk add make nasm autoconf automake libtool dpkg pkgconfig libpng libpng-dev g++
[4/4] Building fresh packages...
Done in 170.33s.
Saving cache for successful job
00:27
Creating cache master-1...
node_modules/: found 82747 matching files and directories
WARNING: .cache/: no matching files
WARNING: public/: no matching files
Uploading cache.zip to https://storage.googleapis.com/gitlab-com-runners-cache/project/...
Created cache
Cleaning up file based variables
00:01
Job succeeded
[4/4] Building fresh packages...
error /builds/my_project/gatsby/node_modules/mozjpeg: Command failed.
Exit code: 1
Command: node lib/install.js
Arguments:
Directory: /builds/my_project/gatsby/node_modules/mozjpeg
Output:
⚠ spawn /builds/my_project/gatsby/node_modules/mozjpeg/vendor/cjpeg ENOENT
⚠ mozjpeg pre-build test failed
ℹ compiling from source
✖ Error: Command failed: /bin/sh -c autoreconf -fiv
/bin/sh: autoreconf: not found
at /builds/my_project/gatsby/node_modules/bin-build/node_modules/execa/index.js:231:11
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async Promise.all (index 0)
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Cleaning up file based variables
00:01
ERROR: Job failed: exit code 1
OS information from: image: "node:lts-alpine"
package.json
information:
npmPackages:
gatsby: ^2.31.1 => 2.31.1
gatsby-image: ^2.10.0 => 2.10.0
gatsby-plugin-manifest: ^2.11.0 => 2.11.0
gatsby-plugin-material-ui: ^2.1.10 => 2.1.10
gatsby-plugin-offline: ^3.9.0 => 3.9.0
gatsby-plugin-react-helmet: ^3.9 => 3.9.0
gatsby-plugin-sharp: ^2.13.4 => 2.13.4
gatsby-source-filesystem: ^2.10.0 => 2.10.0
gatsby-theme-firebase: ^1.0.10 => 1.0.10
gatsby-transformer-sharp: ^2.11.0 => 2.11.0
npmGlobalPackages:
gatsby-cli: 2.17.0
Upvotes: 1
Reputation: 29316
According to some GitHub threads:
They suggest to:
nasm
(highly recommended)automake
, autoconf
, libtool
, dpkg
, pkgconfig
, libpng
, libpng-dev
, g++
Upvotes: 14