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

Next.js执行npm run dev时报错TypeError: root.markClean is not a function

Next.js执行build/export后dev编译失败:TypeError: root.markClean is not a function

问题详情

项目原本运行正常,执行npm run build和npm run export操作后,每次启动npm run dev都会触发编译失败,错误信息如下:

Failed to compile

Next.js (14.2.7)
./src/@menu/styles/styles.module.css
TypeError: root.markClean is not a function

涉及的CSS文件./src/@menu/styles/styles.module.css内容为:

.ul {
  list-style-type: none;
  padding: 0;
  margin: 0;
}

解决方法

  • 清理编译缓存:删除项目根目录下的.next文件夹,以及node_modules/.cache目录,之后重新执行npm run dev
  • 调整Next.js配置:检查next.config.js中的output配置项——执行export后该配置会被设为export,而开发模式下不需要这个设置,可临时注释或删除该配置后重启开发服务
  • 重置依赖:删除package-lock.json(或yarn.lock)和node_modules文件夹,执行npm install重新安装所有依赖,避免依赖缓存冲突
  • 验证路径别名:项目中使用了@menu这种带@的目录别名,确认jsconfig.json或tsconfig.json里的paths配置是否正确,确保开发模式下能正常解析该路径

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.06.19 00:18:10