不能启动vue ui 直接运行,会报错如下:
failed to load config from /Users/xiaochen/IdeaProjects/ChatViewer-frontend/vite.config.ts
error when starting dev server:
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/win32-x64" package is present but this platform
needs the "@esbuild/darwin-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.
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.
at generateBinPath (/Users/xiaochen/IdeaProjects/ChatViewer-frontend/node_modules/esbuild/lib/main.js:1884:17)
at esbuildCommandAndArgs (/Users/xiaochen/IdeaProjects/ChatViewer-frontend/node_modules/esbuild/lib/main.js:1965:33)
at ensureServiceIsRunning (/Users/xiaochen/IdeaProjects/ChatViewer-frontend/node_modules/esbuild/lib/main.js:2129:25)
at build (/Users/xiaochen/IdeaProjects/ChatViewer-frontend/node_modules/esbuild/lib/main.js:2021:26)
at bundleConfigFile (file:///Users/xiaochen/IdeaProjects/ChatViewer-frontend/node_modules/vite/dist/node/chunks/dep-abb4f102.js:66002:26)
at loadConfigFromFile (file:///Users/xiaochen/IdeaProjects/ChatViewer-frontend/node_modules/vite/dist/node/chunks/dep-abb4f102.js:65978:31)
at resolveConfig (file:///Users/xiaochen/IdeaProjects/ChatViewer-frontend/node_modules/vite/dist/node/chunks/dep-abb4f102.js:65575:34)
at _createServer (file:///Users/xiaochen/IdeaProjects/ChatViewer-frontend/node_modules/vite/dist/node/chunks/dep-abb4f102.js:64846:26)
at createServer (file:///Users/xiaochen/IdeaProjects/ChatViewer-frontend/node_modules/vite/dist/node/chunks/dep-abb4f102.js:64843:12)
at CAC.<anonymous> (file:///Users/xiaochen/IdeaProjects/ChatViewer-frontend/node_modules/vite/dist/node/cli.js:743:30)
cd /Users/xiaochen/IdeaProjects/ChatViewer-frontend
这里是我的项目目录,注意切换到自己的项目目录
node_modules 目录和 package-lock.json 文件rm -rf node_modules package-lock.json
sudo chown -R $(whoami) /Users/xiaochen/IdeaProjects/ChatViewer-frontend
不然会报错:
11:41:14 [vite] error while updating dependencies:
Error: EACCES: permission denied, mkdir '/Users/xiaochen/IdeaProjects/ChatViewer-frontend/node_modules/.vite/deps_temp_b5dfa112'
at Object.mkdirSync (node:fs:1372:26)
at runOptimizeDeps (file:///Users/xiaochen/IdeaProjects/ChatViewer-frontend/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:45821:10)
at runOptimizer (file:///Users/xiaochen/IdeaProjects/ChatViewer-frontend/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:45267:38)
at rerun (file:///Users/xiaochen/IdeaProjects/ChatViewer-frontend/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:45400:9)
at Timeout._onTimeout (file:///Users/xiaochen/IdeaProjects/ChatViewer-frontend/node_modules/vite/dist/node/chunks/dep-41cf5ffd.js:45470:17)
at listOnTimeout (node:internal/timers:573:17)
at process.processTimers (node:internal/timers:514:7)
npm install
npm run dev
