我试图将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.
1条答案
按热度按时间nlejzf6q1#
您已经将
node_modules
从本地环境复制到容器中。在本地,您有darwin-arm 64 arch的包,但在容器内部,它是一个Linux系统,需要linux-arm 64的包。为了避免这样的错误,您不应该将node_modules复制到容器中。
您只需要将node_modules添加到
.dockerignore
文件中