uniapp 运行报错
我 · 更新于 2024/7/6
这个错误如何解决 uniapp报错
ailed to load config from /Users/www/wwwroot/vue/xxx/vite.config.ts
18:50:36.612 error when starting dev server:
18:50:36.612 Error:
18:50:36.612 You installed esbuild for another platform than the one you’re currently using.
18:50:36.612 This won’t work because esbuild is written with native code and needs to
18:50:36.612 install a platform-specific binary executable.
18:50:36.612 Specifically the “@esbuild/darwin-arm64” package is present but this platform
18:50:36.612 needs the “@esbuild/darwin-x64” package instead. People often get into this
18:50:36.612 situation by installing esbuild with npm running inside of Rosetta 2 and then
18:50:36.612 trying to use it with node running outside of Rosetta 2, or vice versa (Rosetta
18:50:36.612 2 is Apple’s on-the-fly x86_64-to-arm64 translation service).
18:50:36.612 If you are installing with npm, you can try ensuring that both npm and node are
18:50:36.612 not running under Rosetta 2 and then reinstalling esbuild. This likely involves
18:50:36.612 changing how you installed npm and/or node. For example, installing node with
18:50:36.613 the universal installer here should work: https://nodejs.org/en/download/. Or
18:50:36.613 you could consider using yarn instead of npm which has built-in support for
18:50:36.613 installing a package on multiple platforms simultaneously.
18:50:36.613 If you are installing with yarn, you can try listing both “arm64” and “x64”
18:50:36.613 in your “.yarnrc.yml” file using the “supportedArchitectures” feature:
18:50:36.613 https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
18:50:36.613 Keep in mind that this means multiple copies of esbuild will be present.
18:50:36.613 Another alternative is to use the “esbuild-wasm” package instead, which works
18:50:36.613 the same way on all platforms. But it comes with a heavy performance cost and
18:50:36.613 can sometimes be 10x slower than the “esbuild” package, so you may also not
18:50:36.613 want to do that.
以下是解决方案
第一步、运行以下命令
yarn add esbuild-darwin-arm64
第二步、修改以下文件
0.15.18,但是官方编译却要求0.16.17,所以调整路径/node_modules/esbuild/lib/main.js的文件,全局替换了0.16.17为0.15.18