Module not found: Error: Can't resolve 'zlib' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/body-parser/lib' 해결법

     

     

     

    로그인 파트 구현하는데 갑작스럽게 아래에 나와있는 엄청난 양의 에러가 뜨기 시작했다.

    Compiled with problems:
    ×
    ERROR in ./node_modules/body-parser/lib/read.js 19:11-26
    Module not found: Error: Can't resolve 'zlib' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/body-parser/lib'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "zlib": require.resolve("browserify-zlib") }'
    	- install 'browserify-zlib'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "zlib": false }
    ERROR in ./node_modules/body-parser/lib/types/urlencoded.js 201:12-34
    Module not found: Error: Can't resolve 'querystring' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/body-parser/lib/types'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "querystring": require.resolve("querystring-es3") }'
    	- install 'querystring-es3'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "querystring": false }
    ERROR in ./node_modules/content-disposition/index.js 21:15-39
    Module not found: Error: Can't resolve 'path' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/content-disposition'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
    	- install 'path-browserify'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "path": false }
    ERROR in ./node_modules/cookie-signature/index.js 5:13-30
    Module not found: Error: Can't resolve 'crypto' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/cookie-signature'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
    	- install 'crypto-browserify'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "crypto": false }
    ERROR in ./node_modules/destroy/index.js 15:17-41
    Module not found: Error: Can't resolve 'fs' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/destroy'
    ERROR in ./node_modules/destroy/index.js 16:13-30
    Module not found: Error: Can't resolve 'stream' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/destroy'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
    	- install 'stream-browserify'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "stream": false }
    ERROR in ./node_modules/destroy/index.js 17:11-26
    Module not found: Error: Can't resolve 'zlib' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/destroy'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "zlib": require.resolve("browserify-zlib") }'
    	- install 'browserify-zlib'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "zlib": false }
    ERROR in ./node_modules/etag/index.js 20:13-30
    Module not found: Error: Can't resolve 'crypto' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/etag'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "crypto": require.resolve("crypto-browserify") }'
    	- install 'crypto-browserify'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "crypto": false }
    ERROR in ./node_modules/etag/index.js 21:12-31
    Module not found: Error: Can't resolve 'fs' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/etag'
    ERROR in ./node_modules/express/lib/application.js 22:11-26
    Module not found: Error: Can't resolve 'http' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/express/lib'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
    	- install 'stream-http'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "http": false }
    ERROR in ./node_modules/express/lib/application.js 29:14-37
    Module not found: Error: Can't resolve 'path' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/express/lib'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
    	- install 'path-browserify'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "path": false }
    ERROR in ./node_modules/express/lib/request.js 17:11-30
    Module not found: Error: Can't resolve 'net' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/express/lib'
    ERROR in ./node_modules/express/lib/request.js 19:11-26
    Module not found: Error: Can't resolve 'http' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/express/lib'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
    	- install 'stream-http'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "http": false }
    ERROR in ./node_modules/express/lib/response.js 20:11-26
    Module not found: Error: Can't resolve 'http' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/express/lib'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "http": require.resolve("stream-http") }'
    	- install 'stream-http'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "http": false }
    ERROR in ./node_modules/express/lib/response.js 23:11-26
    Module not found: Error: Can't resolve 'path' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/express/lib'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
    	- install 'path-browserify'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "path": false }
    ERROR in ./node_modules/express/lib/utils.js 23:18-40
    Module not found: Error: Can't resolve 'querystring' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/express/lib'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "querystring": require.resolve("querystring-es3") }'
    	- install 'querystring-es3'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "querystring": false }
    ERROR in ./node_modules/express/lib/view.js 16:11-26
    Module not found: Error: Can't resolve 'path' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/express/lib'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
    	- install 'path-browserify'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "path": false }
    ERROR in ./node_modules/express/lib/view.js 17:9-22
    Module not found: Error: Can't resolve 'fs' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/express/lib'
    ERROR in ./node_modules/mime-types/index.js 15:14-37
    Module not found: Error: Can't resolve 'path' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/mime-types'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
    	- install 'path-browserify'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "path": false }
    ERROR in ./node_modules/mime/mime.js 1:11-26
    Module not found: Error: Can't resolve 'path' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/mime'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
    	- install 'path-browserify'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "path": false }
    ERROR in ./node_modules/mime/mime.js 2:9-22
    Module not found: Error: Can't resolve 'fs' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/mime'
    ERROR in ./node_modules/parseurl/index.js 14:10-24
    Module not found: Error: Can't resolve 'url' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/parseurl'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
    	- install 'url'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "url": false }
    ERROR in ./node_modules/safe-buffer/index.js 3:13-30
    Module not found: Error: Can't resolve 'buffer' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/safe-buffer'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "buffer": require.resolve("buffer/") }'
    	- install 'buffer'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "buffer": false }
    ERROR in ./node_modules/safer-buffer/safer.js 5:13-30
    Module not found: Error: Can't resolve 'buffer' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/safer-buffer'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "buffer": require.resolve("buffer/") }'
    	- install 'buffer'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "buffer": false }
    ERROR in ./node_modules/send/index.js 22:9-22
    Module not found: Error: Can't resolve 'fs' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/send'
    ERROR in ./node_modules/send/index.js 27:11-26
    Module not found: Error: Can't resolve 'path' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/send'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
    	- install 'path-browserify'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "path": false }
    ERROR in ./node_modules/send/index.js 29:13-30
    Module not found: Error: Can't resolve 'stream' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/send'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
    	- install 'stream-browserify'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "stream": false }
    ERROR in ./node_modules/send/index.js 30:11-26
    Module not found: Error: Can't resolve 'util' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/send'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "util": require.resolve("util/") }'
    	- install 'util'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "util": false }
    ERROR in ./node_modules/serve-static/index.js 18:14-37
    Module not found: Error: Can't resolve 'path' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/serve-static'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
    	- install 'path-browserify'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "path": false }
    ERROR in ./node_modules/serve-static/index.js 20:10-24
    Module not found: Error: Can't resolve 'url' in '/Users/yebeen/web/12_study-matching-service/sms/node_modules/serve-static'
    
    BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
    This is no longer the case. Verify if you need this module and configure a polyfill for it.
    
    If you want to include a polyfill, you need to:
    	- add a fallback 'resolve.fallback: { "url": require.resolve("url/") }'
    	- install 'url'
    If you don't want to include a polyfill, you can use an empty module like this:
    	resolve.fallback: { "url": false }

     

     

     

    멘붕에 빠져 해결책을 찾아보는데

    webpack 버전 5에서 기본적으로 node.js의 핵심 모듈에 대한 폴리필을 제공하지 않는다는

    변경사항 때문에 발생하는 것이라고 이것저것 해결책이 있었으나 

    적용해 봐도 해결은 되지 않고 멘탈이 바사삭... 거렸다.

     

    어찌어찌 한 시간을 헤매다 원인을 찾았는데

    8번 라인에 보면 response가 추가돼있는 걸 볼 수 있다.

     

     

     

     

    내가 추가한 적이 없는데 도대체 언제 추가된 것인지 너무 억울했고 왜 추가된 건지 찾아봤는데

    try문에서 선언한 response를 try 밖의 catch문에서 사용하면서

    import { response } from "express"가 추가돼버린 것이다.。 ゚(゚´ω`゚) ゚。

    import문을 지워주고 코드를 올바르게 고쳐주니 에러는 전부 사라졌다.

          try {
            setEmailError(false);
            setIdError(false);
            const response = await axios.post(`${BASE_URL}/join`, {
              username,
              userid,
              password,
              ckpassword,
              email,
              birth,
              gender,
              img,
            });
            if (response.status === 201) {
              navigate("/login");
            }
          } catch (error) {
            if(response.status===400){
              if(response.errorpart==="id"){
                setIdError(true);
              }
              else if(response.errorpart==="email"){
                setEmailError(true);
              }
            }
            else if(response.status===500){
            }
          }

     

     

     

    왠지 이런 오류... 개발하다 보면 또 발생할 것 같아서 

    미래의 나를 위해 적어둔다...

     

     

     

    댓글