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

启动Next.js项目时出现模块缺失错误:找不到caniuse-lite相关模块

Next.js启动报错:Cannot find module 'caniuse-lite/data/features/css-unicode-bidi'

错误详情

启动Next.js项目时触发以下错误:

error - ./node_modules/next/dist/build/webpack/loaders/css-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[1]!./node_modules/next/dist/build/webpack/loaders/postcss-loader/src/index.js??ruleSet[1].rules[2].oneOf[8].use[2]!./styles/globals.css

Error: Cannot find module 'caniuse-lite/data/features/css-unicode-bidi'

对应的调用栈信息:

Require stack:

- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/compiled/postcss-preset-env/index.cjs
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/build/webpack/config/blocks/css/plugins.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/build/webpack/config/blocks/css/index.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/build/webpack/config/index.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/build/webpack-config.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/server/dev/hot-reloader.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/server/dev/next-dev-server.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/server/next.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/server/lib/start-server.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/cli/next-dev.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/lib/commands.js
- /home/ragil/Documents/study/framework/testing/node_modules/next/dist/bin/next

注:已尝试通过npm和yarn重新安装Next.js,问题未解决。

解决步骤

  • 单独安装缺失的caniuse-lite包:
    • npm命令:npm install caniuse-lite --save-dev
    • yarn命令:yarn add caniuse-lite --dev
  • 若上述方法无效,清理依赖缓存并重装所有依赖:
    • 使用npm:
      1. 执行npm cache clean --force清理缓存
      2. 删除项目根目录下的node_modules文件夹和package-lock.json文件
      3. 执行npm install重装依赖
    • 使用yarn:
      1. 执行yarn cache clean清理缓存
      2. 删除项目根目录下的node_modules文件夹和yarn.lock文件
      3. 执行yarn install重装依赖
  • 检查版本兼容性:查看当前Next.js版本对caniuse-lite的版本要求,安装对应版本的包(可在项目package.json的peerDependencies或Next.js官方文档中确认)

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.19 17:05:20