记录一个问题(前端umi4项目挂载docker容器问题)

893 阅读1分钟

关键词

本地电脑mac m1芯片, umi4, docker。 dockerfile: FROM node:18.0.0 MAINTAINER ryan ADD . /app WORKDIR /app RUN npm install CMD npm start

问题描述

把本地目录挂载到docker容器,运行docker run -p 9090:8000 --name website -v project/ol-website:/app -d website:v1.0,容器无法running 直接停止 docker logs website 查看报错信息

报错信息

error - Error:  You installed esbuild for 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.

If you are installing with npm, you can try not copying the "node_modules"

directory when you copy the files over, and running "npm ci" or "npm install"

on the destination platform after the copy. Or you could consider using yarn

instead of npm which has built-in support for installing a package on multiple

platforms simultaneously.

大概意思是esbuild报错“@esbuild/darwin-arm64这个包无法兼容,需要安装@esbuild/linux-arm64这个包 但是前者并不是我写在package.json中安装的,是umi中自带的打包工具esbuild下的依赖包,

问题

不知道怎么解决。。记录一下