Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not found: Can't resolve 'fs' 오류 #3

Open
JuyeolRyu opened this issue Apr 18, 2021 · 1 comment
Open

Module not found: Can't resolve 'fs' 오류 #3

JuyeolRyu opened this issue Apr 18, 2021 · 1 comment

Comments

@JuyeolRyu
Copy link
Owner

JuyeolRyu commented Apr 18, 2021

Module not found: Can't resolve 'fs' 오류

image


'fs' 모듈은 프론트엔드에서 사용되면 안되는데 프론트에서 'fs' 모듈이 호출되는 경우 이 오류가 발생합니다.

해결 방법

  1. 프론트 코드에서 'fs'를 직접 사용하거나 'fs' 모듈을 사용하는 모듈을 제거해 준다. (ex. express)
  2. next를 사용하는 경우 next.config.js 파일을 생성해서 아래의 코드를 추가해준다.
module.exports = {
  webpack: (config, { isServer }) => {
    // Fixes npm packages that depend on `fs` module
    if (!isServer) {
      config.node = {
        fs: 'empty'
      }
    }
    return config
  }
}

참고 : vercel/next.js#7755

@JuyeolRyu
Copy link
Owner Author

나의 경우 프론트 코드에서 express 모듈을 호출하면서 발생한 문제
vscode 자동완성 기능이 문제였음.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant