首页 > 解决方案 > 使用 next.js,为什么我突然开始看到 Module not found: Error: Can't resolve 'fs'?

问题描述

我什么都没改变,但正在使用"next": "9.4.4",我看到:

Module not found: Can't resolve 'fs' in 'web/node_modules/graceful-fs'
Could not find files for /app/d/[id] in .next/build-manifest.json
ModuleNotFoundError: Module not found: Error: Can't resolve 'fs' in 'web/node_modules/graceful-fs'

我可能做错了什么?

标签: node.jswebpacknext.js

解决方案


看起来你不在/api目录中。客户端代码无法导入fs,只有 API 文件可以


推荐阅读