I am trying to containerise Svelte js app inside a docker container and I am getting this error on the log complaining about esbuild in a different platform , I am using M1 mac, I have tried to install esbuild-wasm
as what the log suggested and tried npm i esbuild-linux-arm64
as a step in the docker file and tried RUN npm install yarn
as the log suggested yarn as it have built-in stuff deal with the platform but it didn't work
my docker file
FROM node:16.10.0
WORKDIR /my-website
COPY package.json .
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]
the error is
You installed esbuild on another platform than the one you're currently using.
This won't work because esbuild is written with native code and needs to
install a platform-specific binary executable.
Specifically the "esbuild-darwin-arm64" package is present but this platform
needs the "esbuild-linux-arm64" package instead. People often get into this
situation by installing esbuild on Windows or macOS and copying "node_modules"
into a Docker image that runs Linux, or by copying "node_modules" between
Windows and WSL environments.
You've copied node_modules
from your local environment to the container. Locally you have packages for the darwin-arm64 arch, but inside the container, it is a Linux system that requires packages for linux-arm64.
To avoid such errors you should not copy node_modules to the container.
All you need is to add node_modules to .dockerignore
file
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With