(node:13176) [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:13176) [DEP_WEBPACK_DEV_SERVER_ON_BEFORE_SETUP_MIDDLEWARE] DeprecationWarning: 'onBeforeSetupMiddleware' option is deprecated. Please use the 'setupMiddlewares' option
I had the same error.
An authentication middleware, in my case AWS Amplify Auth, was changed incorrectly and my webpack config yielded an error. The fix for me was to re-install clean then debug the error.
So delete package-lock.json, delete the node-modules folder, and reinstall with "npm i".
Although this does not get to the root of the issue it should work to at least bring up the Dev Server to view any errors.
This is a deprecation warning, meaning that you need to start using the newly suggested way of configuring your middleware. Instead of onBeforeSetupMiddleware and onAfterSetupMiddleware, use the setupMiddlewares-property.
The documentation itself can be found on Webpack's website (in this case here: https://webpack.js.org/configuration/dev-server/#devserversetupmiddlewares)
The configuration will look something like this (coming from onBeforeSetupMiddleware and onAfterSetupMiddleware):
setupMiddlewares: (middlewares, devServer) => {
middleware1(devServer.app)
middleware2(devServer.app)
return middlewares
},
Another useful way of fixing this issue is by looking at the code others have written to fix this issue. I found this example to be helpful: https://github.com/facebook/docusaurus/pull/6168
I faced the same error while adding a proxy middleware npm package to a react project.
The warning was successfully resolved by running.
npm audit fix --force
It's just a deprecation warning from one of the libraries you used within the app, have you tried to open http://localhost:3000 on your local? it is supposed to be running fine