系统:MacOs V13
芯片: M2 Pro
在安装依赖【"@dcloudio/uni-cli-shared": "3.0.0-alpha-3040520220408002",】的时候, 会顺带安装esbuild-darwin的包。
两个uniapp项目中,最早安装的依赖是esbuild-darwin-64。 但是现在不管是用npm yarn 还是pnpm 安装的都是esbuild-darwin-arm64。
导致uniapp在允许到Android手机的时候会报错:
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-darwin-64" 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 which has built-in support for installing a package on multiple
platforms simultaneously.
If you are installing with yarn, you can try listing both this platform and the
other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
Keep in mind that this means multiple copies of esbuild will be present.
Another alternative is to use the "esbuild-wasm" package instead, which works
the same way on all platforms. But it comes with a heavy performance cost and
can sometimes be 10x slower than the "esbuild" package, so you may also not
want to do that.
所以应该怎么使得安装shared依赖的时候安装【esbuild-darwin-64】呢
yeardlry (作者)
我自己新建了一个类似的项目 这个时候npm i后esbuild就对了,原本的项目就不行 就很神奇 不知道哪里配置了东西
2023-07-07 10:50