I have next.js app, before deploying to stand it builds on company servers, where we use a proxy, respectively I'm using the proxy for yarn
yarn config set proxy http://xx.xxx.xx:xxxx
yarn config set httpsProxy http://xx.xxx.xx:xxxx
yarn config set httpProxy http://xx.xxx.xx:xxxx
yarn config set https-proxy http://xx.xxx.xx:xxxx
yarn config set https_proxy http://xx.xxx.xx:xxxx
yarn config set http-proxy http://xx.xxx.xx:xxxx
yarn config set http_proxy http://xx.xxx.xx:xxxx
Unfortunately, it doesn't help and I still see the error during the build
[5/5] Building fresh packages...
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
error /app/node_modules/sharp: Command failed.
Exit code: 1
Command: (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
Arguments:
Directory: /app/node_modules/sharp
Output:
sharp: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.10.6/libvips-8.10.6-linuxmusl-x64.tar.br
sharp: Installation error: tunneling socket could not be established, cause=connect ECONNREFUSED 127.0.0.1:80
sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies
error building image: error building stage: failed to execute command: waiting for process to exit: exit status 1
It seems like there are no problems with packages that were installed from yarn registry. Do you have any ideas?
Had similar problem, trying to install npm sharp package behind proxy failed on downloading libvips on ETIMEOUT.
You can download libvips*.tar.br from the link in error to your local computer and then move downloaded file to repository.
Then, in project root (where you run npm i command) create empty file named .npmrc and paste sharp_libvips_local_prebuilds="libvips-#YOUR_VERSION_HERE#-#YOUR_ENV#.tar.br" inside (just copypaste file name).
Note this is just what is in sharp documentation and in future, you may need to update the downloaded file (eg when sharp version update and req. newer libvips). Or freeze sharp version.
Also, if your local env is different from server (windows x linux), it won't work (probably🙃) - check documentation about this.
You can also try asking your IT (whose are taking care of proxy) if they can somehow add url of libvips source to "whitelist" so your local npm i command could access it.
Any better approach is welcome.
PS noted that youre using yarn instead npm so you will need .yarnrc or similar file instead .npmrc.