docker 您将esbuild安装在了当前使用的平台之外的其他平台上

bwitn5fc  于 2023-05-06  发布在  Docker
关注(0)|答案(1)|浏览(489)

我试图将Svelte js应用程序容器化到docker容器中,我在日志中收到此错误,抱怨esbuild在不同的平台上,我使用的是M1 mac,我已经尝试按照日志建议安装esbuild-wasm,并尝试将npm i esbuild-linux-arm64作为docker文件中的一个步骤,并尝试将RUN npm install yarn作为日志建议的yarn,因为它已经构建-在处理平台的东西,但它没有工作我的docker文件

FROM node:16.10.0
WORKDIR /my-website
COPY package.json .
RUN npm install
COPY . .
EXPOSE 3000
CMD ["npm", "start"]

误差是

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.
nlejzf6q

nlejzf6q1#

您已经将node_modules从本地环境复制到容器中。在本地,您有darwin-arm 64 arch的包,但在容器内部,它是一个Linux系统,需要linux-arm 64的包。
为了避免这样的错误,您不应该将node_modules复制到容器中。
您只需要将node_modules添加到.dockerignore文件中

相关问题