Search code examples
node.jslinuxdockernpmgatsby

Gatsby build failing on mozjpeg


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:

  • locking gatsby-cli
  • adding automake linux package
  • adding libtools linux package
  • unfreezing yarn lock
  • installing dependencies without lock file

But 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


Solution

  • According to some GitHub threads:

    They suggest to:

    • Installing nasm (highly recommended)
    • If the solution above doesn't work, install automake, autoconf, libtool, dpkg, pkgconfig, libpng, libpng-dev, g++
    • Remove cache