I know this question is already answered and yeah a couple of months ago this worked for me as well
but recently I started a new project where I wanted to couple a react app with express and I tried using the same setup and suddenly got the error below:
Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options has an unknown property 'writeToDisk'. These properties are valid:
object { allowedHosts?, bonjour?, client?, compress?, devMiddleware?, headers?, historyApiFallback?, host?, hot?, http2?, https?, ipc?, liveReload?, magicHtml?, onAfterSetupMiddleware?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, server?, setupExitSignals?, setupMiddlewares?, static?, watchFiles?, webSocketServer? }
error Command failed with exit code 1.
Since this QA has helped me back then I decided to share what I found here for anyone who is reading this in future and is getting the same error.
Solution
There seems to be some changes to webpack config "devserver" structure which you can find here: https://webpack.js.org/configuration/dev-server/
Where you can not use writeToDisk directly anymore and need to put it in a devMiddleware object like below:
module.exports = {
devServer: {
devMiddleware: {
writeToDisk: true,
},
},
//...
}
I am using: craco: ^6.4.3
I hope this helps someone who faced the same issue as me