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.9k stars 1.29k forks source link

Install failed with 'sharp_local_prebuilds' #3154

Closed juliusdev closed 2 years ago

juliusdev commented 2 years ago

Hi,

I have an issue with the sharp installation, behind a http proxy which filter access to Github. According the doc, the fallback is to set the 'sharp_local_prebuilds' npm config or the 'npm_config_sharp_local_prebuilds' env variable before install.

Here my .npmrc file content : sharp_local_prebuilds=/mnt/d/Dev/Projects/testsharp/libvips-8.12.2-linux-x64.tar.br

I checked the npm config 'sharp_local_prebuilds'

npm config get sharp_local_prebuilds
/mnt/d/Dev/Projects/testsharp/libvips-8.12.2-linux-x64.tar.br

Here my env var :

 echo $npm_config_sharp_local_prebuild
/mnt/d/Dev/Projects/testsharp/libvips-8.12.2-linux-x64.tar.br

Now when I trying to install sharp with npm, the script try again to download the lib from github repository and fail.

Possible install-time or require-time problem

Are you using the latest version of sharp?

If you cannot confirm this, please upgrade to the latest version and try again before opening an issue.

If you are using another package which depends on a version of sharp that is not the latest, please open an issue against that package instead.

Is this a problem with filesystem permissions?

If you are using npm v6 or earlier and installing as a root or sudo user, have you tried with the npm install --unsafe-perm flag?

If you are using npm v7 or later, does the user running npm install own the directory it is run in?

If you are using the ignore-scripts feature of npm, have you tried with the npm install --ignore-scripts=false flag?

What is the complete output of running npm install --verbose sharp?

npm verb enoent npm WARN testsharp No description npm WARN testsharp No repository field. npm WARN testsharp No README data npm WARN testsharp No license field. npm verb stack Error: sharp@0.30.3 install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)` npm verb stack Exit status 1 npm verb stack at EventEmitter. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16) npm verb stack at EventEmitter.emit (events.js:400:28) npm verb stack at ChildProcess. (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14) npm verb stack at ChildProcess.emit (events.js:400:28) npm verb stack at maybeClose (internal/child_process.js:1058:16) npm verb stack at Process.ChildProcess._handle.onexit (internal/child_process.js:293:5) npm verb pkgid sharp@0.30.3 npm verb cwd /mnt/d/Dev/Projects/testsharp npm verb Linux 5.10.16.3-microsoft-standard-WSL2 npm verb argv "/usr/bin/node" "/usr/bin/npm" "i" "--verbose" "sharp" npm verb node v14.19.0 npm verb npm v6.14.16 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! sharp@0.30.3 install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)` npm ERR! Exit status 1

What is the output of running npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp?

System: OS: Linux 5.10 Ubuntu 20.04.3 LTS (Focal Fossa) CPU: (4) x64 Intel(R) Core(TM) i3-8100 CPU @ 3.60GHz Memory: 10.07 GB / 12.38 GB Container: Yes Shell: 5.0.17 - /bin/bash Binaries: Node: 14.19.0 - /usr/bin/node Yarn: 1.22.17 - /mnt/c/Users/5120/AppData/Roaming/npm/yarn npm: 6.14.16 - /usr/bin/npm
lovell commented 2 years ago

Hi, the sharp_local_prebuilds environment variable refers to the prebuilt binaries for sharp, not libvips.

https://sharp.pixelplumbing.com/install#custom-prebuilt-binaries

https://github.com/lovell/sharp/releases/tag/v0.30.3

https://github.com/prebuild/prebuild-install#local-prebuilds

juliusdev commented 2 years ago

It's my mistake 🤐

I uploaded the libvips and sharp binaries on the company Nexus repository and set the following variables in my .npmrc

sharp_libvips_binary_host=https://nexus.xxxx.x/repository/raw-repo/libvips
sharp_binary_host=https://nexus.xxxxx.x/repository/raw-repo/sharp

Thanks ! it works fine 👍

dirjk commented 2 years ago

@lovell I am also behind a proxy and unable to download the libvips binaries from github. However, I do not have a server that I can upload them to as a host, like @juliusdev did.

npm_config_sharp_libvips_binary_host does not work and neither does sharp_libvips_binary_host which I assume is because, as the documentation says, those are for custom URLs and require a server.

Are there variables that can be set to have the libvips binaries loaded from a local file path? I am hoping there are libvips equivalents of sharp_local_prebuilds and npm_config_sharp_local_prebuilds.

thank you!

lovell commented 2 years ago

@dirjk sharp will always looks for a globally-installed libvips at npm install time, so for environments where you do not have network access at install time, you'll need to arrange for libvips to be installed in whatever manner you use for other OS-level dependencies.

ricovitch commented 2 years ago

I'm also stucked on installing sharp behind a proxy on MacOS.

I followed this steps

My .npmrc file looks like this :

sharp_local_prebuilds=~/Dev/tools/libvips/sharp-v0.30.3-napi-v5-darwin-x64.tar.gz

npm install fail with this error

npm ERR! sharp: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.12.2/libvips-8.12.2-darwin-x64.tar.br
npm ERR! sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies
npm ERR! sharp: Installation error: read ECONNRESET
lovell commented 2 years ago

@ricovitch Please open a new installation issue and answer all of the questions if you still require help.

ricovitch commented 2 years ago

Ok sure I'll do that thank you for the fast answer.

jebolivarb commented 6 months ago

Hello, I was checking it and it was not possible to find a solution with the indicated steps. I created the .npmrc file in my project with the requested content and the error still persists. The truth is, I have done everything and it has not been possible for me to find a solution.

sharp_local_prebuilds= C:\Users\Jehico.Bolívar\base-baileys-memory\libvips-8.12.2-win32-x64.tar.br sharp_libvips_binary_host=https://github.com/lovell/sharp-libvips/releases/download/v8.12.2/libvips-8.12.2-win32-x6 sharp_binary_host=sharp_binary_host=https://github.com/lovell/sharp/releases/tag/v0.33.2

machine specifications Windows 10 Pro - 64 bits

npm ERR! code 1 npm ERR! path C:\Users\Jehico.Bolívar\base-baileys-memory\node_modules\sharp npm ERR! command failed npm ERR! command C:\Windows\system32\cmd.exe /d /s /c (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy) npm ERR! sharp: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.12.2/libvips-8.12.2-win32-x6/v8.12.2/libvips-8.12.2-win32-x64.tar.br npm ERR! sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies npm ERR! sharp: Installation error: self-signed certificate in certificate chain

npm ERR! A complete log of this run can be found in: C:\Users\Jehico.Bolívar\AppData\Local\npm-cache_logs\2024-03-06T20_15_26_970Z-debug-0.log

lovell commented 6 months ago

For anyone coming here, please upgrade to the latest version of sharp, currently v0.33.2, and this entire class of problem goes away (see #3750 for context).