onAfterSetupMiddleware is Deprecated | onBeforeSetupMiddleware is Deprecated 문제 해결방법

KoEunseo·2022년 11월 17일
2

fixErr

목록 보기
8/23

(node:2584) [DEP_WEBPACK_DEV_SERVER_ON_AFTER_SETUP_MIDDLEWARE] DeprecationWarning: 'onAfterSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.
(Use node --trace-deprecation ... to show where the warning was created)
(node:2584) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option.

해결방법

https://www.youtube.com/watch?v=ifSTp9WEHpo
https://github.com/DrVipinKumar/ReactAllProjects/blob/main/reactwithspring/public/MiddlewareDeprecationSolution.txt

node_module -> react-scripts -> config -> webpackDevServer.config.js클릭 -> 112번째줄에 onBeforeSetupMiddleware, 123번째줄에 onAfterSetupMiddleware이 있음
111번째줄에 proxy, 이부분 바로 아래부터 닫히는 중괄호와 콤마가 있는 줄까지 아래 코드로 변경

setupMiddlewares: (middlewares, devServer) => {
    if (!devServer) {
        throw new Error('webpack-dev-server is not defined')
    }
    if (fs.existsSync(paths.proxySetup)) {
        require(paths.proxySetup)(devServer.app)
    }
    middlewares.push(
        evalSourceMapMiddleware(devServer),
        redirectServedPath(paths.publicUrlOrPath),
        noopServiceWorkerMiddleware(paths.publicUrlOrPath)
    )
    return middlewares;
},

--------------- 해결완! --------------
이런 에러가 난다....ㅠㅠㅠㅠㅠ 왜때문이지.....ㅠㅠㅠㅠ
문제가 저런 문구가 나온 후에 일단 시작은 된다는 것임...

깃허브에서 어떤분이 올려주신 해결책
https://github.com/facebook/create-react-app/issues/12035
My way of solving this was... npm run build, then npm install -g serve,
npx serve -s build.
I couldn't figure out the webpack shit!! and the problem lied with the npm start so instead I used npx serve -s build... hope it helps!

스택오버플로우에서 찾은 해결책
https://stackoverflow.com/questions/70469717/cant-load-a-react-app-after-starting-server
지금 다른분들은 작업이 잘되고있다고 해서... 이건 일단 패스하고 다른방법을 찾아보기로 함.

지금 로그인.js 파일이 문제인 것 같아서 그 파일이 없는 브랜치를 다시 다운받아왔다.
백엔드에서 작업하고계신분이 계속 머지를 반복하고 계셔서 메인 브랜치로 클론이 되어서 자꾸 안됨...ㅠㅠ

git clone -b {특정브랜치명} --single-branch {클론할url경로}

profile
주니어 플러터 개발자의 고군분투기

0개의 댓글