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 are using Docker like I am and come across this issue.

Most likely your `node_modules` folder is being copied from your host machine into the docker container.

Why? Because your `node_modules` folder downloads modules specific to the architecture of your machine (in my case Mac), when you take these packages and try to run them in the container OS, it causes issues because the binaries are for mac (darwin-x64) and it tries to run them on linux (linux-x64) inside the container

To fix it, create a file named `.dockerignore` in the same directory as your `Dockerfile` and updated them accordingly.

`.dockerignore`

```
node_modules/

```

`Dockerfile`

```
FROM node:latest
WORKDIR /usr/src/app
COPY package*.json ./
RUN ["npm", "install"]
COPY . .
CMD ["npm", "start"]

```
If you use SAM you could build your function inside an AWS Lambda-like Linux Docker container:

```
sam build -u

```