React前端运行报错[plugin:vite:react-swc] Bindings not found求助
解决Vite+React-SWC的「Bindings not found」报错
报错信息
运行React应用时出现:
[plugin:vite:react-swc] Bindings not found
调用栈关键路径:C:/Users/jonus/OneDrive/Desktop/real-estate-app/client/src/main.jsx
涉及@swc/core和@vitejs/plugin-react-swc相关调用
解决办法
清理依赖重新安装
- 删除
node_modules文件夹和package-lock.json/yarn.lock - 运行
npm install或者yarn install重新安装依赖 - 重启Vite服务
- 删除
对齐SWC相关依赖版本
版本不匹配是常见诱因,尝试重新安装最新兼容版本:npm uninstall @swc/core @vitejs/plugin-react-swc npm install @vitejs/plugin-react-swc@latest @swc/core@latest修复Windows环境特殊问题
你的项目放在OneDrive同步文件夹,容易引发文件冲突,建议移到本地普通目录(比如C:\Projects\real-estate-app);另外可以:- 用管理员权限打开命令行操作
- 安装Windows构建工具:
npm install -g windows-build-tools(需管理员权限)
临时切换到Babel插件
如果以上方法无效,可替换SWC为Vite官方Babel插件:- 卸载SWC插件:
npm uninstall @vitejs/plugin-react-swc - 安装Babel插件:
npm install @vitejs/plugin-react - 修改
vite.config.js/vite.config.ts:import { defineConfig } from 'vite' import react from '@vitejs/plugin-react' export default defineConfig({ plugins: [react()] })
- 卸载SWC插件:
内容的提问来源于stack exchange,提问作者Jonus
相关产品推荐
相关产品推荐

