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

使用Yarn创建Next.js项目时出现“Cannot find module”错误

Yarn 创建 Next.js 项目出现「Cannot find module」错误的解决

问题场景

  • 通过Yarn创建Next.js项目,执行命令顺序为:
    yarn create next-app → yarn install → yarn cache clean → yarn build
  • 执行后编辑器抛出Cannot find module错误
  • 多次重新创建项目、更换不同编辑器,使用Yarn进行相关操作均会触发该报错

解决步骤

切换至npm重新完成项目初始化与构建,问题即可解决:

  1. 删除之前用Yarn创建的项目文件夹
  2. 执行 npx create-next-app@latest 初始化新项目
  3. 进入项目目录后运行 npm install
  4. 最后执行 npm run build 完成项目构建

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.19 00:27:02