webpack配置报错:Invalid options object.
前言:
今天在使用webpack进行项目配置的时候,运行之后终端报错: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?, ipc?, liveReload?, onListening?, open?, port?, proxy?, server?, setupExitSignals?, setupMiddlewares?, static?, watchFiles?, webSocketServer? }
遇到报错不要慌,先打开看一下,这一段报错是什么意思:无效的选项对象。Dev Server 已使用与 API 架构不匹配的 options 对象进行初始化。- options 具有未知属性“inline”。这些属性是有效的:object { allowedHosts?, bonjour?, client?, compress?, devMiddleware?, headers?, historyApiFallback?, host?, hot?, ipc?, liveReload?, onListening?, open?, port?, proxy?, server?, setupExitSignals?, setupMiddlewares?, static?, watchFiles?, webSocketServer?}
原来是配置中的inline属性已经无效了,我们把它注释掉或者删除就可以解决问题
其中在webpack中disableHostCheck属性在版本更新中已经被allowedHosts属性替换,所以在webpack5版本中使用disableHostCheck,也会报类似的错误,如果需要使用此属性,请使用allowedHosts属性替代。在webpack4版本及以下依旧需要使用disableHostCheck属性,请各位小伙伴们注意自己的webpack版本
原文地址:https://blog.csdn.net/gurenchang/article/details/140641491
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!