• 把Vue项目从Window系统迁移到Mac系统的方案


    不能启动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)
    

    解决方案

    1. 导航到项目目录
      在终端中,使用 cd 命令导航到项目目录:
    cd /Users/xiaochen/IdeaProjects/ChatViewer-frontend
    
    

    这里是我的项目目录,注意切换到自己的项目目录

    1. 删除 node_modules 目录和 package-lock.json 文件
    rm -rf node_modules package-lock.json
    
    
    1. 授权用户修改权限
    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)
    
    1. 重新安装依赖
    npm install
    
    1. 启动项目
    npm run dev
    

    在这里插入图片描述

  • 相关阅读:
    微信小程序-form表单-获取用户输入文本框的值
    关于前端的文件下载问题,通过超链接a无法自定义文件名
    查询 (Tcode)跳转ID方法:(SET PARAMETER ID)
    《吐血整理》进阶系列教程-拿捏Fiddler抓包教程(9)-Fiddler如何设置捕获Https会话
    孙子兵法_00000
    游戏测试的概念是什么?测试方法和流程有哪些?
    OpenCVSharp图像形态学操作
    python用pip安装第三方库提示:Can’t connect to HTTPS URL because the SSL module...的解决办法
    前端缓存
    hive笔记(三):DDL数据定义/DML数据操作-数据库、表、数据导入导出
  • 原文地址:https://blog.csdn.net/weixin_43993064/article/details/139699664