ValidationError: Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.

   在进行 webpack-dev-server 相关配置时,运行项目出现以上报错,我的 vue.config.js 配置如下:

module.exports = {
  lintOnSave: false,
  runtimeCompiler: true,
  publicPath: '/', 
  // 输出文件目录
  outputDir: 'dist',
  productionSourceMap: false,
  // webpack-dev-server 相关配置
  devServer: {
    open: false, //是否自动弹出浏览器页面
    host: '0.0.0.0',
    port: '8000',
    https: false,
    hotOnly: false,
    historyApiFallback: true,
    proxy: {
      '/api': {
        target: 'http://192.168.50.260:8081', 
        ws: true, //代理websockets
        changeOrigin: true, 
        pathRewrite: {
          '^/api': '',
        },
      },
    },
  },
};

 

  解决方案

  注意报错信息的提示,修改 hotOnly

  将    修改为   

 

  原因

  webpack-dev-server 版本问题,如果你使用的是4,应该使用 迁移指南

 

posted @ 2022-07-28 14:35  打遍天下吴敌手  阅读(5134)  评论(0编辑  收藏  举报