yeardlry
yeardlry
  • 发布:2023-07-04 16:00
  • 更新:2024-09-03 10:30
  • 阅读:2604

MacOs M2芯片,打包报错:esbuild-darwin-arm64

分类:uni-app

系统: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】呢

2023-07-04 16:00 负责人:DCloud_UNI_OttoJi 分享
已邀请:
1***@qq.com

1***@qq.com

我和你一样 MAC M2 vue3+vite4, 好像M2用M1的方法处理不了(至少目前我没解决),建议直接抛弃HbuildX编译器,我直接用vscode 运行和开发的 就没有esbuild 这个编译版本问题

  • yeardlry (作者)

    我自己新建了一个类似的项目 这个时候npm i后esbuild就对了,原本的项目就不行 就很神奇 不知道哪里配置了东西

    2023-07-07 10:50

1***@qq.com

1***@qq.com

哥们解决了吗?

森林互动

森林互动

相同错误。。。

7***@qq.com

7***@qq.com

我是用NVM使用的时候会这样,换回系统原生的时候又正常了

w***@163.com

w***@163.com

试试使用 pnpm install --force 强制重新安装所有依赖项。我是m3pro芯片出现了这个问题,现在好了。

我不是地球人

我不是地球人

什么方式都尝试了,还是不行

要回复问题请先登录注册