Question: When attempting to run sharp inside an AWS Lambda function, I keep getting the following error:

> 
> darwin-x64' binaries cannot be used on the 'linux-x64' platform.
>  Please remove the 'node\_modules/sharp/vendor' directory and run 'npm
>  install'
> 
> 
> 

I deploy my serverless applications with Serverless Framework from my MacBook Pro. How do I fix this problem?

Answer: 
If you like to `yarn`, set via environment variables

NOTE: I clean up the existing platform/arch first.

```sh
# For macOS/Windows, we can install natively
yarn remove sharp
yarn add sharp

# For AWS Lambda, we need to specify this when we package:
yarn remove sharp
npm_config_platform=linux npm_config_arch=x64 yarn add sharp

```
For anyone stumbling upon this post now. I've accomplished this by copying my `package.json` file into an [AWS Cloud9 IDE](https://aws.amazon.com/cloud9/) and simply running `npm install`. From there, just download the `node_modules/` folder.