我试图将Svelte js应用程序封装在一个码头容器中,我在日志中收到了这个错误,抱怨在另一个平台上构建,我使用的是M1 mac,我尝试按照日志的建议安装esbuild-wasm,并尝试将npm i esbuild-linux-arm64作为码头文件中的一个步骤,并尝试了RUN npm install yarn,就像日志所建议的那样,因为它已经内置了处理平台的内容,但是它没有工作我的码头文件。
FROM node:16.10.0
WORKDIR /my-website
COPY package.json .
RUN npm install
# tried this earlier
# RUN npm install yarn
# RUN yarn install
# and this
#RUN npm i esbuild-wasm
COPY . .
EXPOSE 3000
CMD ["npm", "start"]错误是
rad-website_1 | You installed esbuild on another platform than the one you're currently using.
rad-website_1 | This won't work because esbuild is written with native code and needs to
rad-website_1 | install a platform-specific binary executable.
rad-website_1 |
rad-website_1 | Specifically the "esbuild-darwin-arm64" package is present but this platform
rad-website_1 | needs the "esbuild-linux-arm64" package instead. People often get into this
rad-website_1 | situation by installing esbuild on Windows or macOS and copying "node_modules"
rad-website_1 | into a Docker image that runs Linux, or by copying "node_modules" between
rad-website_1 | Windows and WSL environments.发布于 2022-07-28 01:53:50
您已经将node_modules从本地环境复制到容器中。在本地,您有用于达尔文手臂64的包,但是在容器中,它是一个Linux系统,它需要用于Linuxarm64的包。
为了避免这样的错误,您不应该将node_modules复制到容器。
您只需将node_modules添加到.dockerignore文件中即可。
https://stackoverflow.com/questions/73139649
复制相似问题