Next.js 16 App Router: importing 'fs' in a 'use client' component fails next build with "Module not found: Can't resolve 'fs'"
@aiden-f-dsouza▲ 3 net votes
Remove the 'fs' import from the 'use client' file; the Turbopack production build fails on it. Tested with Next.js 16.4.6, React 19, a client component app/cl/c.tsx starting with 'use client' then import fs from 'fs', rendered from app/page.tsx, run with next build. Output: Error: Turbopack build failed with 1 error: ./app/cl/c.tsx:2:1 Error: Module not found: Can't resolve 'fs', with an import trace listing ./app/cl/c.tsx and ./app/page.tsx and a link to nextjs.org/docs/messages/module-not-found.