lovell / sharp

High performance Node.js image processing, the fastest module to resize JPEG, PNG, WebP, AVIF and TIFF images. Uses the libvips library.
https://sharp.pixelplumbing.com
Apache License 2.0
28.91k stars 1.29k forks source link

centos pm2 run error and Input buffer contains unsupported image format #2703

Closed sujiewen closed 3 years ago

sujiewen commented 3 years ago

node v12.16.1 sharp 0.28.1 centos 7.7

Question 1: pm2 start ecosystem.config.js --env production --watch unable to work normally

0|www | - Remove the "node_modules/sharp" directory then run 0|www | "npm install --ignore-scripts=false --verbose sharp" and look for errors 0|www | - Consult the installation documentation at https://sharp.pixelplumbing.com/install 0|www | - Search for this error at https://github.com/lovell/sharp/issues 0|www | 0|www | at Object. (/BlueOcean/WebServer/nodeserver/tesths/node_modules/sharp/lib/constructor.js:32:9) 0|www | at Module._compile (internal/modules/cjs/loader.js:1158:30) 0|www | at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10) 0|www | at Module.load (internal/modules/cjs/loader.js:1002:32) 0|www | at Function.Module._load (internal/modules/cjs/loader.js:901:14) 0|www | at Module.require (internal/modules/cjs/loader.js:1044:19) 0|www | at Module.Hook._require.Module.require (/usr/local/lib/node_modules/pm2/node_modules/require-in-the-middle/index.js:80:39) 0|www | at require (internal/modules/cjs/helpers.js:77:18) 0|www | at Object. (/BlueOcean/WebServer/nodeserver/tesths/node_modules/sharp/lib/index.js:3:15) 0|www | at Module._compile (internal/modules/cjs/loader.js:1158:30) Error: Something went wrong installing the "sharp" module

libvips-cpp.so.42: cannot open shared object file: No such file or directory

[root@223 tesths]# ldd node_modules/sharp/build/Release/sharp.node linux-vdso.so.1 => (0x00007fff9e7f0000) libvips-cpp.so.42 => /usr/local/lib/libvips-cpp.so.42 (0x00007f4710aca000) libvips.so.42 => /usr/local/lib/libvips.so.42 (0x00007f471041b000) libgobject-2.0.so.0 => /lib64/libgobject-2.0.so.0 (0x00007f47101ca000) libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007f470feb4000) libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007f470fbac000) libm.so.6 => /lib64/libm.so.6 (0x00007f470f8aa000) libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f470f694000) libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f470f478000) libc.so.6 => /lib64/libc.so.6 (0x00007f470f0aa000) libz.so.1 => /lib64/libz.so.1 (0x00007f470ee94000) libpng15.so.15 => /lib64/libpng15.so.15 (0x00007f470ec69000) libgmodule-2.0.so.0 => /lib64/libgmodule-2.0.so.0 (0x00007f470ea65000) libgio-2.0.so.0 => /lib64/libgio-2.0.so.0 (0x00007f470e6c5000) libexpat.so.1 => /lib64/libexpat.so.1 (0x00007f470e49b000) libpcre.so.1 => /lib64/libpcre.so.1 (0x00007f470e239000) libffi.so.6 => /lib64/libffi.so.6 (0x00007f470e031000) /lib64/ld-linux-x86-64.so.2 (0x00007f4710f43000) libdl.so.2 => /lib64/libdl.so.2 (0x00007f470de2d000) libselinux.so.1 => /lib64/libselinux.so.1 (0x00007f470dc06000) libresolv.so.2 => /lib64/libresolv.so.2 (0x00007f470d9ec000) libmount.so.1 => /lib64/libmount.so.1 (0x00007f470d7a9000) libblkid.so.1 => /lib64/libblkid.so.1 (0x00007f470d569000) libuuid.so.1 => /lib64/libuuid.so.1 (0x00007f470d364000)

[root@iZrj9bvwbk0d6f4hs9en3iZ lib]# pkg-config --modversion vips-cpp 8.10.6

Question 2: PORT=10001 node ./bin/www

sharp(roundedCorners1).png().toBuffer() .then( data => { resolve(data) }) .catch( err => { console.log('sharp =' + err) reject(err) } )

Error: Input buffer contains unsupported image format,This code works fine on macos

lovell commented 3 years ago

libvips-cpp.so.42 => /usr/local/lib/libvips-cpp.so.42 (0x00007f4710aca000)

It looks like you're using a globally-installed libvips, so please ensure it was compiled with support for the input image formats you need.

sujiewen commented 3 years ago

Not globally-installed libvips?

I install the following third-party libraries yum install libjpeg yum install libjpeg-devel yum install libtiff yum install libtiff-devel yum install freetype yum install libungif yum install libungif-devel yum install ImageMagick yum install librsvg2-devel

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Follow the steps below to reinstall sharp: rm -rf node_modules/sharp

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// [root@iZbp17cxmmtvxonswp3939Z server]# PORT=10001 node ./bin/www /root/server/node_modules/sharp/lib/constructor.js:32 throw new Error(error); ^

Error: Something went wrong installing the "sharp" module

libvips-cpp.so.42: cannot open shared object file: No such file or directory

lovell commented 3 years ago

What's the output of the following command?

ldd /root/server/node_modules/sharp/build/Release/sharp.node
sujiewen commented 3 years ago

Sorry, Need to associate configuration! vim  /etc/profile add export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib/ source /etc/profile