fs 모듈은 node.js에서 컴퓨터의 파일 시스템에 접근하여 읽고 사용하기 위한 모듈이다.
그래서 클라이언트에서 fs 모듈을 사용할려고하면 Module not found: Can't resolve 'fs'와 같은 에러 표시가 발생하게 된다.
이 문제를 해결하기 위해서는 웹펙을 설정하면 해결이 된다.
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
};
module.exports = nextConfig;
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
swcMinify: true,
webpack: (config, { isServer }) => {
if (!isServer) {
config.resolve.fallback = {
fs: false,
};
}
return config;
},
};
module.exports = nextConfig;