Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

yarn platform specific install? #2340

Closed
markbayor opened this issue Aug 26, 2020 · 6 comments
Closed

yarn platform specific install? #2340

markbayor opened this issue Aug 26, 2020 · 6 comments

Comments

@markbayor
Copy link

How does one do this with Yarn?

I've tried yarn add --arch=x64 --platform=linux --target=10.16.0 sharp but nothing is being installed into node_modules

Originally posted by @zkrige in #1459 (comment)

@markbayor markbayor changed the title Still interested in resolving this yarn platform specific install? Aug 26, 2020
@lovell
Copy link
Owner

lovell commented Aug 26, 2020

The --target flag is no longer required.

https://sharp.pixelplumbing.com/install#aws-lambda

npm install --arch=x64 --platform=linux sharp

However it looks like yarn doesn't support --arch - see yarnpkg/yarn#2221 for a possible workaround.

@cyberwombat
Copy link

Posting it for convenience:

SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm_config_arch=x64 npm_config_platform=linux yarn add sharp

@RBrNx
Copy link

RBrNx commented Jun 1, 2021

@cyberwombat Did you get the above command to work?

I ran it, along with sls deploy to deploy my lambda to AWS, but when I try to use the lambda it errors with "'darwin-x64' binaries cannot be used on the 'linux-x64' platform. Please remove the 'node_modules/sharp' directory and run 'npm install' on the 'linux-x64' platform." which suggests that Yarn isn't paying attention to those config flags 🤔

EDIT:
For anyone else stumbling across this in the future, I was able to create a .npmrc file, alongside my package.json, which contains the two config properties described above:

arch=x64
platform=linux

After deploying this change to my lambdas, they started working

@cyberwombat
Copy link

@RBrNx glad it's working. The command does work for me which i confirmed when running tests - told me i had a linux binary. That being said deployment to awa lambda using the cdk did not work. What I did was make a folder and installed sharp in it and then deployed as a lambda layer. That worked great and allowed me to maintain my darwin lib locally

@PlatonSotnykov
Copy link

PlatonSotnykov commented Mar 1, 2024

I have npm v.10.5.0 and yarn v.1.22.21.
The following command does work and installs the proper binary versions in the node_modules/@img folder:

npm install --cpu=x64 --os=linux sharp

But this one does not:

SHARP_IGNORE_GLOBAL_LIBVIPS=1 npm_config_arch=x64 npm_config_platform=linux yarn add sharp --ignore-engines

The latter one still installs sharp-darvin-x64. Without the --ignore-engines it does not install any binaries at all.
What am I doing wrong?

@lovell
Copy link
Owner

lovell commented Mar 1, 2024

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

Repository owner locked and limited conversation to collaborators Mar 1, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants