You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

每次安装新包后Vite更新依赖时持续报错求助

Vite安装新包后重启服务器报错问题

每次安装新包、修改代码集成对应功能并重启服务器时,都会触发报错,报错前控制台会输出提示:Re-optimizing dependencies because lockfile has changed。

曾尝试按照报错提示重命名文件夹,但没有效果。目前只能通过删除node_modules文件夹后重新安装依赖解决,且需要反复尝试多次才能成功。

报错截图

vite.config.js 配置

import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
  server: {
    hmr: false,
  },
  optimizeDeps: {
    exclude: ["js-big-decimal", "chunk_react"],
  },
});

package.json 内容

{
  "name": "frontend",
  "private": true,
  "version": "0.0.0",
  "type": "module",
  "scripts": {
    "dev": "vite",
    "build": "vite build",
    "lint": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0",
    "preview": "vite preview"
  },
  "dependencies": {
    "@hello-pangea/dnd": "^16.5.0",
    "axios": "^1.6.7",
    "react": "^18.2.0",
    "react-beautiful-dnd": "^13.1.1",
    "react-dom": "^18.2.0",
    "react-icons": "^5.0.1",
    "react-router-dom": "^6.22.0",
    "react-wavify": "^1.10.0",
    "zod": "^3.22.4"
  },
  "devDependencies": {
    "@types/react": "^18.2.43",
    "@types/react-dom": "^18.2.17",
    "@vitejs/plugin-react": "^4.2.1",
    "autoprefixer": "^10.4.17",
    "eslint": "^8.55.0",
    "eslint-plugin-react": "^7.33.2",
    "eslint-plugin-react-hooks": "^4.6.0",
    "eslint-plugin-react-refresh": "^0.4.5",
    "postcss": "^8.4.33",
    "tailwindcss": "^3.4.1",
    "vite": "^5.0.8"
  }
}

内容的提问来源于stack exchange,提问作者Sarthak Khanduja

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.30 00:35:21