接手了別人的項目,在配置 devServer 時直接照搬了之前的配置結果報錯
ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options has an unknown property 'disableHostCheck'. 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? }
ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
這段報錯信息意思是Dev Server已使用與API模式不匹配的選項對象初始化,其中明確指出是屬性 ‘disableHostCheck’,于是我屏蔽了這個屬性,發(fā)現(xiàn)能啟動成功
此時我查看了之前和這次的項目的webpack的版本發(fā)現(xiàn)這次的版本是 webpack5 之前是webpack4,并且查看了webpack的文檔發(fā)現(xiàn)
‘disableHostCheck’ 這個屬性在webpack4中已經(jīng)被刪除替換,webpack5中已經(jīng)不存在這個屬性了,所以配置這個會報錯,正確做法是替換成文章來源:http://www.zghlxwxcb.cn/news/detail-505430.html
devServer: {
historyApiFallback: true,
allowedHosts: "all"
},
OK!文章來源地址http://www.zghlxwxcb.cn/news/detail-505430.html
到了這里,關于Vue.config.js 配置報錯 ValidationError: Invalid options object.的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!