Cannot install node modules due to optipng-bin and mozjpeg

134 views Asked by At

I'm trying to install a cloned project with npm and I have this error due to optipng-bin or mozjpeg sometimes :

npm ERR! code 1
npm ERR! path /Users/antoinekurka/Documents/Wastern/wastern-vue/node_modules/optipng-bin
npm ERR! command failed
npm ERR! command sh -c -- node lib/install.js
npm ERR! compiling from source
npm ERR! spawn Unknown system error -86
npm ERR! optipng pre-build test failed
npm ERR! Error: Command failed: /bin/sh -c make install
npm ERR! pngrtran.c:99:1: warning: unused function 'png_rtran_ok' [-Wunused-function]
npm ERR! png_rtran_ok(png_structrp png_ptr, int need_IHDR)
npm ERR! ^
npm ERR! 1 warning generated.
npm ERR! pngrutil.c:3536:20: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
npm ERR!                    png_isaligned(dp, png_uint_16) &&
npm ERR!                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ./pngpriv.h:597:29: note: expanded from macro 'png_isaligned'
npm ERR!    (((type)((const char*)ptr-(const char*)0) & \
npm ERR!                             ^~~~~~~~~~~~~~~
npm ERR! pngrutil.c:3537:20: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
npm ERR!                    png_isaligned(sp, png_uint_16) &&
npm ERR!                    ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ./pngpriv.h:597:29: note: expanded from macro 'png_isaligned'
npm ERR!    (((type)((const char*)ptr-(const char*)0) & \
npm ERR!                             ^~~~~~~~~~~~~~~
npm ERR! pngrutil.c:3544:23: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
npm ERR!                   if (png_isaligned(dp, png_uint_32) &&
npm ERR!                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ./pngpriv.h:597:29: note: expanded from macro 'png_isaligned'
npm ERR!    (((type)((const char*)ptr-(const char*)0) & \
npm ERR!                             ^~~~~~~~~~~~~~~
npm ERR! pngrutil.c:3545:23: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
npm ERR!                       png_isaligned(sp, png_uint_32) &&
npm ERR!                       ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
npm ERR! ./pngpriv.h:597:29: note: expanded from macro 'png_isaligned'
npm ERR!    (((type)((const char*)ptr-(const char*)0) & \
npm ERR!                             ^~~~~~~~~~~~~~~
npm ERR! pngrutil.c:4604:34: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
npm ERR!          int extra = (int)((temp - (png_bytep)0) & 0x0f);
npm ERR!                                  ^ ~~~~~~~~~~~~
npm ERR! pngrutil.c:4608:30: warning: performing pointer subtraction with a null pointer has undefined behavior [-Wnull-pointer-subtraction]
npm ERR!          extra = (int)((temp - (png_bytep)0) & 0x0f);
npm ERR!                              ^ ~~~~~~~~~~~~
npm ERR! 6 warnings generated.
npm ERR! ld: warning: -s is obsolete
npm ERR! ld: Undefined symbols:
npm ERR!   _png_init_filter_functions_neon, referenced from:
npm ERR!       _png_read_filter_row in libpng.a[10](pngrutil.o)
npm ERR! clang: error: linker command failed with exit code 1 (use -v to see invocation)
npm ERR! make[1]: *** [optipng] Error 1
npm ERR! make: *** [install] Error 2
npm ERR!
npm ERR! cd src/optipng && \
npm ERR!    /Library/Developer/CommandLineTools/usr/bin/make install && \
npm ERR!    cd ../..
npm ERR! cd ../libpng && \
npm ERR!    /Library/Developer/CommandLineTools/usr/bin/make -f Makefile PNGLIBCONF_H_PREBUILT=pnglibconf.h.optipng && \
npm ERR!    cd ../optipng
npm ERR! cp pnglibconf.h.optipng pnglibconf.h
npm ERR! gcc -c -I../zlib  -O2 -Wall -Wextra -o png.o png.c
npm ERR! gcc -c -I../zlib  -O2 -Wall -Wextra -o pngerror.o pngerror.c
npm ERR! gcc -c -I../zlib  -O2 -Wall -Wextra -o pngget.o pngget.c
npm ERR! gcc -c -I../zlib  -O2 -Wall -Wextra -o pngmem.o pngmem.c
npm ERR! gcc -c -I../zlib  -O2 -Wall -Wextra -o pngpread.o pngpread.c
npm ERR! gcc -c -I../zlib  -O2 -Wall -Wextra -o pngread.o pngread.c
npm ERR! gcc -c -I../zlib  -O2 -Wall -Wextra -o pngrio.o pngrio.c
npm ERR! gcc -c -I../zlib  -O2 -Wall -Wextra -o pngrtran.o pngrtran.c
npm ERR! gcc -c -I../zlib  -O2 -Wall -Wextra -o pngrutil.o pngrutil.c
npm ERR! gcc -c -I../zlib  -O2 -Wall -Wextra -o pngset.o pngset.c
npm ERR! gcc -c -I../zlib  -O2 -Wall -Wextra -o pngtrans.o pngtrans.c
npm ERR! gcc -c -I../zlib  -O2 -Wall -Wextra -o pngwio.o pngwio.c
npm ERR! gcc -c -I../zlib  -O2 -Wall -Wextra -o pngwrite.o pngwrite.c
npm ERR! gcc -c -I../zlib  -O2 -Wall -Wextra -o pngwtran.o pngwtran.c
npm ERR! gcc -c -I../zlib  -O2 -Wall -Wextra -o pngwutil.o pngwutil.c
npm ERR! ar rcs libpng.a png.o pngerror.o pngget.o pngmem.o pngpread.o pngread.o pngrio.o pngrtran.o pngrutil.o pngset.o pngtrans.o pngwio.o pngwrite.o pngwtran.o pngwutil.o
npm ERR! ranlib libpng.a
npm ERR! gcc -c -I../zlib  -O2 -Wall -Wextra -o pngtest.o pngtest.c
npm ERR! gcc  -L../zlib -o pngtest pngtest.o libpng.a -lz -lm
npm ERR! cd ../opngreduc && \
npm ERR!    /Library/Developer/CommandLineTools/usr/bin/make -f Makefile libopngreduc.a && \
npm ERR!    cd ../optipng
npm ERR! gcc -c  -O2 -Wall -Wextra  -I../libpng -o opngreduc.o opngreduc.c
npm ERR! ar cru libopngreduc.a opngreduc.o
npm ERR! ranlib libopngreduc.a
npm ERR! cd ../gifread && \
npm ERR!    /Library/Developer/CommandLineTools/usr/bin/make -f Makefile libgifread.a && \
npm ERR!    cd ../optipng
npm ERR! gcc -c  -O2 -Wall -Wextra -o gifread.o gifread.c
npm ERR! ar cru libgifread.a gifread.o
npm ERR! ranlib libgifread.a
npm ERR! cd ../pnmio && \
npm ERR!    /Library/Developer/CommandLineTools/usr/bin/make -f Makefile libpnmio.a && \
npm ERR!    cd ../optipng
npm ERR! gcc -c  -O2 -Wall -Wextra -o pnmin.o pnmin.c
npm ERR! gcc -c  -O2 -Wall -Wextra -o pnmout.o pnmout.c
npm ERR! gcc -c  -O2 -Wall -Wextra -o pnmutil.o pnmutil.c
npm ERR! ar cru libpnmio.a pnmin.o pnmout.o pnmutil.o
npm ERR! ranlib libpnmio.a
npm ERR! cd ../minitiff && \
npm ERR!    /Library/Developer/CommandLineTools/usr/bin/make -f Makefile libminitiff.a && \
npm ERR!    cd ../optipng
npm ERR! gcc -c  -O2 -Wall -Wextra -o tiffread.o tiffread.c
npm ERR! gcc -c  -O2 -Wall -Wextra -o tiffutil.o tiffutil.c
npm ERR! ar cru libminitiff.a tiffread.o tiffutil.o
npm ERR! ranlib libminitiff.a
npm ERR! cd ../pngxtern && \
npm ERR!    /Library/Developer/CommandLineTools/usr/bin/make -f Makefile libpngxtern.a && \
npm ERR!    cd ../optipng
npm ERR! gcc -c  -O2 -Wall -Wextra  -I../libpng -I../gifread -I../pnmio -I../minitiff -o pngxread.o pngxread.c
npm ERR! gcc -c  -O2 -Wall -Wextra  -I../libpng -I../gifread -I../pnmio -I../minitiff -o pngxrbmp.o pngxrbmp.c
npm ERR! gcc -c  -O2 -Wall -Wextra  -I../libpng -I../gifread -I../pnmio -I../minitiff -o pngxrgif.o pngxrgif.c
npm ERR! gcc -c  -O2 -Wall -Wextra  -I../libpng -I../gifread -I../pnmio -I../minitiff -o pngxrjpg.o pngxrjpg.c
npm ERR! gcc -c  -O2 -Wall -Wextra  -I../libpng -I../gifread -I../pnmio -I../minitiff -o pngxrpnm.o pngxrpnm.c
npm ERR! gcc -c  -O2 -Wall -Wextra  -I../libpng -I../gifread -I../pnmio -I../minitiff -o pngxrtif.o pngxrtif.c
npm ERR! gcc -c  -O2 -Wall -Wextra  -I../libpng -I../gifread -I../pnmio -I../minitiff -o pngxio.o pngxio.c
npm ERR! gcc -c  -O2 -Wall -Wextra  -I../libpng -I../gifread -I../pnmio -I../minitiff -o pngxmem.o pngxmem.c
npm ERR! gcc -c  -O2 -Wall -Wextra  -I../libpng -I../gifread -I../pnmio -I../minitiff -o pngxset.o pngxset.c
npm ERR! ar cru libpngxtern.a pngxread.o pngxrbmp.o pngxrgif.o pngxrjpg.o pngxrpnm.o pngxrtif.o pngxio.o pngxmem.o pngxset.o
npm ERR! ranlib libpngxtern.a
npm ERR! gcc -c  -O2 -Wall -Wextra -I../cexcept  -I../libpng -I../opngreduc -I../pngxtern -o optipng.o optipng.c
npm ERR! gcc -c  -O2 -Wall -Wextra -I../cexcept  -I../libpng -I../opngreduc -I../pngxtern -o optim.o optim.c
npm ERR! gcc -c  -O2 -Wall -Wextra -I../cexcept  -I../libpng -I../opngreduc -I../pngxtern -o bitset.o bitset.c
npm ERR! gcc -c  -O2 -Wall -Wextra -I../cexcept  -I../libpng -I../opngreduc -I../pngxtern -o ioutil.o ioutil.c
npm ERR! gcc -c  -O2 -Wall -Wextra -I../cexcept  -I../libpng -I../opngreduc -I../pngxtern -o ratio.o ratio.c
npm ERR! gcc -c  -O2 -Wall -Wextra -I../cexcept  -I../libpng -I../opngreduc -I../pngxtern -o wildargs.o wildargs.c
npm ERR! gcc -s -o optipng optipng.o optim.o bitset.o ioutil.o ratio.o wildargs.o ../opngreduc/libopngreduc.a ../pngxtern/libpngxtern.a ../libpng/libpng.a  ../gifread/libgifread.a ../pnmio/libpnmio.a ../minitiff/libminitiff.a  -lz -lm
npm ERR!
npm ERR!     at /Users/antoinekurka/Documents/Wastern/wastern-vue/node_modules/bin-build/node_modules/execa/index.js:231:11
npm ERR!     at runMicrotasks (<anonymous>)
npm ERR!     at processTicksAndRejections (node:internal/process/task_queues:96:5)
npm ERR!     at async /Users/antoinekurka/Documents/Wastern/wastern-vue/node_modules/optipng-bin/lib/install.js:17:4

I'm in node 16 and npm 8 on MacOS.

Do someone have any idea why ?

I tried installing many packages like : automake autoconf libtool dpkg pkgconfig nasm libpng also optipng and mozjpeg with brew but still have the same error.

1

There are 1 answers

0
germs12 On

UPDATE

Following this thread worked: https://github.com/imagemin/mozjpeg-bin/issues/64

TL;DR:

brew install automake autoconf libtool m4 nasm libpng pkg-config
sudo ln -s /opt/homebrew/Cellar/libpng/1.6.40/lib/libpng16.a /usr/local/lib/libpng16.a

Original

I hit this exact same error. I found a path forward by uninstalling nodejs and reinstalling it. In my case I am using asdf.

asdf uninstall nodejs <version>

I then reinstalled it with

asdf install nodejs <version>

And then ran

npm i

Good luck!