-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Error: Could not load the "sharp" module using the linux-x64 runtime on AWS Lambda #4001
Comments
Update: Following the execution of |
https://sharp.pixelplumbing.com/install#aws-lambda If you still require help, please open a new installation issue and answer all of the questions. |
I am seeing the same issue @tpamsler you mentioned that as the solution but, for me running the |
My result from |
I just ran |
@tpamsler if you run that on your local machine or otherwise if you can see what went into the lambda, do you see what hte binaries are in the node_modules. Going into the node_modules/@img I see |
Here is what I have in my node_modules/@img
```
sharp-darwin-arm64
sharp-libvips-darwin-arm64
sharp-libvips-linux-x64
sharp-libvips-linuxmusl-x64
sharp-linux-x64
sharp-linuxmusl-x64
```
…On Fri, Feb 23, 2024 at 6:59 AM Ed Olivares ***@***.***> wrote:
@tpamsler <https://github.com/tpamsler> if you run that on your local
machine or otherwise if you can see what went into the lambda, do you see
what hte binaries are in the node_modules. Going into the node_modules/
@img <https://github.com/img> I see sharp-darwin-x64
sharp-libvips-darwin-x64 but, I actually see the linux values:
***@***.***/sharp-libvips-linux-arm and others in my package-lock
file as I have run that same npm install targeted for linux
—
Reply to this email directly, view it on GitHub
<#4001 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/ART4UNTLBJG2BGISTSHLPPTYVCVGVAVCNFSM6AAAAABDRUVOEGVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSNRRGQ4DKMJZGI>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@tpamsler Would you mind posting your package.json and/or package-lock.json file. I'm interested if there are any diffs between. I can get these linux binaries by doing a |
I hope this helps somebody: For me installing the packages manually was the only way to make it work on AWS, I am using Sharp v0.33.4, this it is probably not a good practice (as mentioned) but at least it works.
|
@lovell
If I install the linux runtime, I can't build it locally because my npm will compain about these incompatible runtimes. OptionalDependencies doesn't work. How do I get the correct dependencies installed in my LambdaLayers for so I can deploy from my mac using cdk deploy? I think when I install the lambda layers via bitbucket pipeline, the machine is linux and it probably fetches the correct dependencies. |
@mattiLeBlanc I've tried every single workaround mentioned here and anywhere else and nothing worked for me. The only thing that worked was adding sharp as a lambda layer. |
@amarsyla yeah, I am using lambda layers. But I have 2 ways of installing:
However, I would like to deploy locally from my mac to Lambda, with the correct binaries for lambda. Maybe that is not possible atm, hence my question to @lovell |
https://sharp.pixelplumbing.com/install#cross-platform The summary is that if you're attempting to run multiple/cross-platform then it's best to use a package manager that supports it. Most other approaches will involve you fighting against your choice of package manager. |
@mattiLeBlanc Instead of building the binaries for the lambda layer I am using prebuilt packages: https://github.com/pH200/sharp-layer This is working great regardless of the deployment method. |
@lovell I am using npm. I guess what I want is to force the lambda layer package.json (npm) to always install the linux runtime because that is what is deployed to the lambda. Is that possible? I just confirmed that my Bitbucket deployed version is working fine because that is all Linux, so I am out of the woods for development, staging and production. |
@amarsyla thank you for this. |
@mattiLeBlanc I am not exactly sure as I am using the serverless framework which makes things easier, but I'm assuming uploading the zip layer and attaching it to the function should do it. I am using release-x64.zip. I am also on a Mac M1 and this has been working great for me. I have also locked the |
@amarsyla |
@amarsyla |
I found an other solution works weel for me.
|
I did what @amarsyla suggests by downloading this file https://github.com/pH200/sharp-layer/releases/tag/0.33.5 and I moved the file to an other directory |
Thanks........... Spent whole day and this was the final workaround |
I, too, did what @amarsyla suggested and it worked. My process was:
|
Possible bug
Is this a possible bug in a feature of sharp, unrelated to installation?
npm install sharp
completes without error.node -e "require('sharp')"
completes without error.If you cannot confirm both of these, please open an installation issue instead.
Are you using the latest version of sharp?
sharp
as reported bynpm view sharp dist-tags.latest
.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.What is the output of running
npx envinfo --binaries --system --npmPackages=sharp --npmGlobalPackages=sharp
?Cannot run above command as it's executed on AWS Lambda nodejs20.x
What are the steps to reproduce?
Execute lambda on AWS Lambfda
What is the expected behaviour?
Lambda function should load "sharp" image library without arrores
Please provide a minimal, standalone code sample, without other dependencies, that demonstrates this problem
const sharp = require('sharp');
Please provide sample image(s) that help explain this problem
{
"errorType": "Error",
"errorMessage": "Could not load the "sharp" module using the linux-x64 runtime\nPossible solutions:\n- Ensure optional dependencies can be installed:\n npm install --include=optional sharp\n yarn add sharp --ignore-engines\n- Ensure your package manager supports multi-platform installation:\n See https://sharp.pixelplumbing.com/install#cross-platform\n- Add platform-specific dependencies:\n npm install --os=linux --cpu=x64 sharp\n- Consult the installation documentation:\n See https://sharp.pixelplumbing.com/install",
"trace": [
"Error: Could not load the "sharp" module using the linux-x64 runtime",
"Possible solutions:",
"- Ensure optional dependencies can be installed:",
" npm install --include=optional sharp",
" yarn add sharp --ignore-engines",
"- Ensure your package manager supports multi-platform installation:",
" See https://sharp.pixelplumbing.com/install#cross-platform",
"- Add platform-specific dependencies:",
" npm install --os=linux --cpu=x64 sharp",
"- Consult the installation documentation:",
" See https://sharp.pixelplumbing.com/install",
" at Object. (/var/task/node_modules/sharp/lib/sharp.js:114:9)",
" at Module._compile (node:internal/modules/cjs/loader:1376:14)",
" at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)",
" at Module.load (node:internal/modules/cjs/loader:1207:32)",
" at Module._load (node:internal/modules/cjs/loader:1023:12)",
" at Module.require (node:internal/modules/cjs/loader:1235:19)",
" at require (node:internal/modules/helpers:176:18)",
" at Object. (/var/task/node_modules/sharp/lib/constructor.js:10:1)",
" at Module._compile (node:internal/modules/cjs/loader:1376:14)",
" at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)"
]
}
The text was updated successfully, but these errors were encountered: