English 中文(简体)
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.
问题回答

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

For what it s worth for anyone running into this without Docker, I had the same issue with an M2 Mac running a node process until I ran:

node -p "process.arch"

Where it then returned "arm64"

After which I nuked my node_modules, ran npm install, and voila!

Full article on the fix: https://blog.hao.dev/fixing-esbuild-related-cpu-architecture-error-on-apple-silicon-macs

I received a very similar error to this when moving my code to a new computer. All I had to do was run npm install and it fixed everything.





相关问题
Unable to connect to docker container inside windows server

As title. I am developing a system with many docker images with ASP.Net MVC core projects. I am publishing these docker images into a docker engine installed on Windows Server OS, and I found that I ...

Only can see postgreSQL as an admin

After installed Wsl and Docker, can t access PSQL and other things. I was studying Docker, and installed the latest version. So far so good, I received an error about the WSL version, saw some ...

make docker-compose block until healthy without `depends_on`

I am working with a team that uses docker-compose to start a set of helper services, but does not use docker when the code is being developed. Here, docker-compose is just a convenient way to run the ...

change grafana port using docker host network

I am trying to spin up a grafana container in docker, however my setup in docker does not allow ipv4 forwarding and thus I cannot use the default bridge network in docker. All I can use is the host ...

Pip instalation for Python 3.11 in docker

I have Dockerfile to build image for Django project that uses Python 3.11 and runs in poetry environment (see content below). Problem is when I try to donwload get-pip.py file and run it using Python, ...

在 Dockerfile 中运行 composer install

我正在尝试将我的Laravel应用程序进行Docker化。 该应用程序已经构建并在Git中,但我将vendor文件夹添加到了.gitignore中。 我添加了一个Dockerfile,看起来像这样: FROM php:7.1-fpm-alpine RUN apk update ...

热门标签