Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

You installed esbuild on another platform than the one you're currently using

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.
like image 255
Yusuf Avatar asked Sep 01 '25 02:09

Yusuf


1 Answers

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

like image 113
Bogdan Onischenko Avatar answered Sep 02 '25 21:09

Bogdan Onischenko