Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options has an unknown property 'inline'. 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? }
出现上面那个问题,和config文件配置有关
json文件中webpack和脚手架还有server的版本
"webpack": "^5.72.1",
"webpack-cli": "^4.9.2",
"webpack-dev-server": "^4.9.0"
然后通过下面这个网址可以发现,可能是我们配置config的时候很多东西都被抛弃了,所以添加进去会出现问题
https://webpack.js.org/configuration/dev-server/
下面这样配置就ok啦
devServer: {
// contentBase: "./dist",
static: {
//本地服务器所加载的页面所在的目录
directory: path.join(__dirname, "./dist"),
},
compress: true,
port: 9000,//端口号
},