When I add this piece of code from sharp package (that is a image processing package):
await sharp(req.file.path)
.resize(500)
.jpeg({ quality: 50 })
.toFile(path.resolve(req.file.destination, “resized”, filename));
I get this error:
Illegal instruction (core dumped)
When I remove it, everything is ok. I’m very confused. What is wrong with that code?
Through my conversation with @Tomalak, it seems that the latest version of sharp is not compatible with my CPU:
Theres nothing wrong with your code. That's a bug in sharp - apparently it tries to use CPU instructions that are not supported on your CPU. Try an older version of sharp. – Tomalak
I tried a couple of older versions. The latest version that works for me is 0.27.2. you can install it using this command:
npm i [email protected]
I also opened an issue on their GitHub page: https://github.com/lovell/sharp/issues/2723#issue-894046354
My environment (npx envinfo --binaries --system):
System: OS: Linux 5.4 Linux Mint 20 (Ulyana) CPU: (2) x64 Pentium(R) Dual-Core CPU E5300 @ 2.60GHz Memory: 172.51 MB / 3.84 GB Container: Yes Shell: 3.2.2 - /usr/bin/fish Binaries: Node: 10.19.0 - /usr/bin/node npm: 7.6.1 - /usr/local/bin/npm
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With