m1 Mac HbuilderX导入Vue3+Vite运行报错

 11:40:53.583 项目 'my-vue3-project' 开始编译...  
11:40:54.457 请注意运行模式下,因日志输出、sourcemap 以及未压缩源码等原因,性能和包体积,均不及发行模式。  
11:40:54.461 正在编译中...  
11:40:54.461 failed to load config from /Users/stephen/code/my-vue3-project/vite.config.js  
11:40:54.464 error when starting dev server:  
11:40:54.467 Error:   
11:40:54.468 You installed esbuild on another platform than the one you're currently using.  
11:40:54.469 This won't work because esbuild is written with native code and needs to  
11:40:54.471 install a platform-specific binary executable.  
11:40:54.480 Specifically the "esbuild-darwin-arm64" package is present but this platform  
11:40:54.480 needs the "esbuild-darwin-64" package instead. People often get into this  
11:40:54.483 situation by installing esbuild on Windows or macOS and copying "node_modules"  
11:40:54.483 into a Docker image that runs Linux, or by copying "node_modules" between  
11:40:54.484 Windows and WSL environments.  
11:40:54.486 If you are installing with npm, you can try not copying the "node_modules"  
11:40:54.487 directory when you copy the files over, and running "npm ci" or "npm install"  
11:40:54.488 on the destination platform after the copy. Or you could consider using yarn  
11:40:54.489 instead which has built-in support for installing a package on multiple  
11:40:54.490 platforms simultaneously.  
11:40:54.492 If you are installing with yarn, you can try listing both this platform and the  
11:40:54.492 other platform in your ".yarnrc.yml" file using the "supportedArchitectures"  
11:40:54.494 feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures  
11:40:54.499 Keep in mind that this means multiple copies of esbuild will be present.  
11:40:54.501 Another alternative is to use the "esbuild-wasm" package instead, which works  
11:40:54.502 the same way on all platforms. But it comes with a heavy performance cost and  
11:40:54.503 can sometimes be 10x slower than the "esbuild" package, so you may also not  
11:40:54.505 want to do that.  
11:40:54.506     at generateBinPath (/Users/stephen/code/my-vue3-project/node_modules/esbuild/lib/main.js:1788:17)  
11:40:54.506     at esbuildCommandAndArgs (/Users/stephen/code/my-vue3-project/node_modules/esbuild/lib/main.js:1872:31)  
11:40:54.508     at ensureServiceIsRunning (/Users/stephen/code/my-vue3-project/node_modules/esbuild/lib/main.js:2034:25)  
11:40:54.510     at Object.build (/Users/stephen/code/my-vue3-project/node_modules/esbuild/lib/main.js:1927:26)  
11:40:54.515     at bundleConfigFile (/Users/stephen/code/my-vue3-project/node_modules/vite/dist/node/chunks/dep-59dc6e00.js:61872:34)  
11:40:54.515     at loadConfigFromFile (/Users/stephen/code/my-vue3-project/node_modules/vite/dist/node/chunks/dep-59dc6e00.js:61849:35)  
11:40:54.518     at resolveConfig (/Users/stephen/code/my-vue3-project/node_modules/vite/dist/node/chunks/dep-59dc6e00.js:61376:34)  
11:40:54.520     at createServer (/Users/stephen/code/my-vue3-project/node_modules/vite/dist/node/chunks/dep-59dc6e00.js:59783:26)  
11:40:54.521     at createServer (/Users/stephen/code/my-vue3-project/node_modules/@dcloudio/vite-plugin-uni/dist/cli/server.js:15:50)  
11:40:54.522     at CAC.runDev (/Users/stephen/code/my-vue3-project/node_modules/@dcloudio/vite-plugin-uni/dist/cli/action.js:21:45)

解决方案

可以锁定版本

pnpm add @esbuild/darwin-x64 -D
or
pnpm add @esbuild/darwin-x64@0.16.17 -D