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

Laravel+Inertia+React构建报错:找不到scheduler/tracing模块及类型声明

解决Laravel+Inertia+React构建时Cannot find module 'scheduler/tracing'错误

问题背景

使用Node 20.13.1 + NPM 10.8.0开发Laravel+Inertia+React应用,npm run dev运行正常,但执行npm run build时触发TypeScript错误:

node_modules/@types/react/index.d.ts:41:53 - error TS2307: Cannot find module 'scheduler/tracing' or its corresponding type declarations.

41 import { Interaction as SchedulerInteraction } from 'scheduler/tracing';

解决方案

1. 安装scheduler的类型依赖

scheduler是React内部依赖,但TypeScript类型包可能未自动安装,手动补充:

npm install @types/scheduler --save-dev

2. 调整TypeScript配置跳过库类型检查

在项目根目录的tsconfig.json中,给compilerOptions添加skipLibCheck配置,跳过第三方库的类型检查,快速规避该错误:

{
  "compilerOptions": {
    // 其他配置...
    "skipLibCheck": true
  }
}

3. 锁定scheduler版本匹配React

React 18.2.0对应依赖的scheduler版本为0.23.2,手动安装该版本确保兼容性:

npm install scheduler@0.23.2 --save

4. 强制统一依赖版本

若存在依赖冲突,在package.json中添加overrides字段强制所有依赖使用指定的scheduler版本:

{
  // 其他配置...
  "overrides": {
    "scheduler": "0.23.2"
  }
}

添加后重新执行npm install。


内容的提问来源于stack exchange,提问作者Matteo Tassinari

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.22 07:47:09