shrinkpack icon indicating copy to clipboard operation
shrinkpack copied to clipboard

A package+version tarball can be insufficient if platform libraries are needed

Open tim-janik opened this issue 2 years ago • 2 comments

Some NPM packages depend on platform libs during installation

Case in point is the sharp package, which requires github.com/.../libvips-8.12.2-linux-x64.tar.br during installation. Using shrinkpack with sharp breaks during offline installs as follows:

$ rm -rf ~/.npm/    # purge NPM cache or run in a clean CI environment
$ npm ci --offline
npm ERR! code 1
npm ERR! path /tmp/bar/node_modules/sharp
npm ERR! command failed
npm ERR! command sh -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-linux-x64.tar.br
npm ERR! sharp: Please see https://sharp.pixelplumbing.com/install for required dependencies
npm ERR! sharp: Installation error: getaddrinfo EAI_AGAIN github.com

The issue is reported here: Unconditional Download during install breaks shrinkpack - sharp#3737

Suggested Solution

It is not clear to me how the needed libvips-8.12.2-linux-x64 could end up in the prepared node_shrinkpack/sharp-0.30.7.tar file, i.e. which project would have to be adjusted, but that would be required in order for npm ci --offline to work.

tim-janik avatar Jul 22 '23 23:07 tim-janik

Thanks @tim-janik, on the face of it I don't think shrinkpack can do anything(?) this is a behaviour of the sharp package right?

JamieMason avatar Jul 24 '23 15:07 JamieMason

Thanks @tim-janik, on the face of it I don't think shrinkpack can do anything(?) this is a behaviour of the sharp package right?

Honestly, I am not sure.

In this issuecomment, @lovell mentiones https://sharp.pixelplumbing.com/install#custom-prebuilt-binaries - so clearly this is something they have spent some thoughts and efforts on. Could there be a way to integrate that automatically with shrinkpack? In the Target Problem description, you mention the case of phantomjs and node-sass which have operating system specific binaries. How is that solved by shrinkpack, and could a variant be applied to sharp?

tim-janik avatar Jul 24 '23 22:07 tim-janik