error while installing “imagemin-mozjpeg” on macOS: npm ERR! spawn Unknown system error -86 | npm ERR! mozjpeg pre-build test failed

  Kiến thức lập trình

I’m using macOS Sonoma v14.4.1 and when I tried to install imagemin-mozjpeg using the following command:

npm i imagemin-mozjpeg

At first I got some errors like npm ERR! /bin/sh: autoreconf: command not found so I installed autoconf along with other packages using brew

brew install autoconf automake libtool

Then I got another error that “The “m4″ command requires the command line developer tools.” so I installed the command line developer tools.

But after that I got the below bunch of errors & I don’t know how to fix them in order to install the npm package imagemin-mozjpeg successfully

Is there maybe some prerequisite packages / tools that I need to install first?

amjed@192 some-project % npm i imagemin-mozjpeg
npm ERR! code 1
npm ERR! path /Users/amjed/some-project/node_modules/mozjpeg
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! mozjpeg pre-build test failed
npm ERR! Error: Command failed: /bin/sh -c ./configure --enable-static --disable-shared --disable-dependency-tracking --with-jpeg8 libpng_LIBS='/usr/local/lib/libpng16.a -lz' --enable-static --prefix="/Users/amjed/some-project/node_modules/mozjpeg/vendor" --bindir="/Users/amjed/some-project/node_modules/mozjpeg/vendor" --libdir="/Users/amjed/some-project/node_modules/mozjpeg/vendor"
npm ERR! ./configure: line 14911: PKG_PROG_PKG_CONFIG: command not found
npm ERR! ./configure: line 15184: syntax error near unexpected token `libpng,'
npm ERR! ./configure: line 15184: `PKG_CHECK_MODULES(libpng, libpng, HAVE_LIBPNG=1,'
npm ERR! 
npm ERR! checking for a BSD-compatible install... /usr/bin/install -c
npm ERR! checking whether build environment is sane... yes
npm ERR! checking for a race-free mkdir -p... mkdir -p
npm ERR! checking for gawk... no
npm ERR! checking for mawk... no
npm ERR! checking for nawk... no
npm ERR! checking for awk... awk
npm ERR! checking whether make sets $(MAKE)... yes
npm ERR! checking whether make supports nested variables... yes
npm ERR! checking whether make supports nested variables... (cached) yes
npm ERR! checking whether make supports the include directive... yes (GNU style)
npm ERR! checking for gcc... gcc
npm ERR! checking whether the C compiler works... yes
npm ERR! checking for C compiler default output file name... a.out
npm ERR! checking for suffix of executables... 
npm ERR! checking whether we are cross compiling... no
npm ERR! checking for suffix of object files... o
npm ERR! checking whether the compiler supports GNU C... yes
npm ERR! checking whether gcc accepts -g... yes
npm ERR! checking for gcc option to enable C11 features... none needed
npm ERR! checking whether gcc understands -c and -o together... yes
npm ERR! checking dependency style of gcc... none
npm ERR! checking how to run the C preprocessor... gcc -E
npm ERR! checking for gcc... (cached) gcc
npm ERR! checking whether the compiler supports GNU C... (cached) yes
npm ERR! checking whether gcc accepts -g... (cached) yes
npm ERR! checking for gcc option to enable C11 features... (cached) none needed
npm ERR! checking whether gcc understands -c and -o together... (cached) yes
npm ERR! checking dependency style of gcc... (cached) none
npm ERR! checking for ar... ar
npm ERR! checking the archiver (ar) interface... ar
npm ERR! checking dependency style of gcc... none
npm ERR! checking the archiver (ar) interface... (cached) ar
npm ERR! checking build system type... aarch64-apple-darwin23.4.0
npm ERR! checking host system type... aarch64-apple-darwin23.4.0
npm ERR! checking how to print strings... printf
npm ERR! checking for a sed that does not truncate output... /usr/bin/sed
npm ERR! checking for grep that handles long lines and -e... /usr/bin/grep
npm ERR! checking for egrep... /usr/bin/grep -E
npm ERR! checking for fgrep... /usr/bin/grep -F
npm ERR! checking for ld used by gcc... /Library/Developer/CommandLineTools/usr/bin/ld
npm ERR! checking if the linker (/Library/Developer/CommandLineTools/usr/bin/ld) is GNU ld... no
npm ERR! checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
npm ERR! checking the name lister (/usr/bin/nm -B) interface... BSD nm
npm ERR! checking whether ln -s works... yes
npm ERR! checking the maximum length of command line arguments... 786432
npm ERR! checking how to convert aarch64-apple-darwin23.4.0 file names to aarch64-apple-darwin23.4.0 format... func_convert_file_noop
npm ERR! checking how to convert aarch64-apple-darwin23.4.0 file names to toolchain format... func_convert_file_noop
npm ERR! checking for /Library/Developer/CommandLineTools/usr/bin/ld option to reload object files... -r
npm ERR! checking for file... file
npm ERR! checking for objdump... objdump
npm ERR! checking how to recognize dependent libraries... pass_all
npm ERR! checking for dlltool... no
npm ERR! checking how to associate runtime and link libraries... printf %sn
npm ERR! checking for archiver @FILE support... no
npm ERR! checking for strip... strip
npm ERR! checking for ranlib... ranlib
npm ERR! checking command to parse /usr/bin/nm -B output from gcc object... ok
npm ERR! checking for sysroot... no
npm ERR! checking for a working dd... /bin/dd
npm ERR! checking how to truncate binary pipes... /bin/dd bs=4096 count=1
npm ERR! checking for mt... no
npm ERR! checking if : is a manifest tool... no
npm ERR! checking for dsymutil... dsymutil
npm ERR! checking for nmedit... nmedit
npm ERR! checking for lipo... lipo
npm ERR! checking for otool... otool
npm ERR! checking for otool64... no
npm ERR! checking for -single_module linker flag... ld: warning: -single_module is obsolete
npm ERR! no
npm ERR! checking for -exported_symbols_list linker flag... yes
npm ERR! checking for -force_load linker flag... yes
npm ERR! checking for stdio.h... yes
npm ERR! checking for stdlib.h... yes
npm ERR! checking for string.h... yes
npm ERR! checking for inttypes.h... yes
npm ERR! checking for stdint.h... yes
npm ERR! checking for strings.h... yes
npm ERR! checking for sys/stat.h... yes
npm ERR! checking for sys/types.h... yes
npm ERR! checking for unistd.h... yes
npm ERR! checking for dlfcn.h... yes
npm ERR! checking for objdir... .libs
npm ERR! checking if gcc supports -fno-rtti -fno-exceptions... yes
npm ERR! checking for gcc option to produce PIC... -fno-common -DPIC
npm ERR! checking if gcc PIC flag -fno-common -DPIC works... yes
npm ERR! checking if gcc static flag -static works... no
npm ERR! checking if gcc supports -c -o file.o... yes
npm ERR! checking if gcc supports -c -o file.o... (cached) yes
npm ERR! checking whether the gcc linker (/Library/Developer/CommandLineTools/usr/bin/ld) supports shared libraries... yes
npm ERR! checking dynamic linker characteristics... darwin23.4.0 dyld
npm ERR! checking how to hardcode library paths into programs... immediate
npm ERR! checking whether stripping libraries is possible... yes
npm ERR! checking if libtool supports shared libraries... yes
npm ERR! checking whether to build shared libraries... no
npm ERR! checking whether to build static libraries... yes
npm ERR! checking whether ln -s works... yes
npm ERR! checking size of size_t... 8
npm ERR! checking whether compiler supports pointers to undefined structures... yes
npm ERR! checking for gcc options needed to detect all undeclared functions... none needed
npm ERR! checking whether __SUNPRO_C is declared... no
npm ERR! checking for pow in -lm... yes
npm ERR! 
npm ERR!     at /Users/amjed/some-project/node_modules/execa/index.js:231:11
npm ERR!     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
npm ERR!     at async Promise.all (index 0)

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/amjed/.npm/_logs/2024-05-09T17_02_52_801Z-debug-0.log

LEAVE A COMMENT