vue2 配置vue.config.js devServer 时报错

 配置vue.config.js devServer 后,启用项目报错。

报错信息:

ERROR 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 'overlay'. 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.
- options has an unknown property 'overlay'. 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? }
at validate (G:\stevenchen\LDProject\ldadminvue\node_modules\webpack-dev-server\node_modules\schema-utils\dist\validate.js:115:11)
at new Server (G:\stevenchen\LDProject\ldadminvue\node_modules\webpack-dev-server\lib\Server.js:231:5)
at serve (G:\stevenchen\LDProject\ldadminvue\node_modules\@vue\cli-service\lib\commands\serve.js:194:20)
at processTicksAndRejections (node:internal/process/task_queues:96:5)

----------vue.config.js 代码如下---------------------------------------------------------------------------------------

import config from 'src/config/index'

module.exports = {
    devServer: {
        host: 'localhost',
        port: 8080,
        open: true,
        /*
        overlay: {
            warnings: false,
            errors: true
        },
        */
        proxy: {
            '/api': {
                target: config.BASE_URL,
                ws: true,
                changOrigin: true,
                pathRewrite: {
                    '^/api': '' // 思路是如果是开发环境,就给所有要代理的接口统一加上前缀,然后代理请求时再统一通过rewrite去掉
                }
            }
        }
    }
}
----------------------------------------
我的处理方法,注释掉这一段,就OK了
 /*
        overlay: {
            warnings: false,
            errors: true
        },
        */
posted @ 2022-10-11 10:10  baivfhpwxf  阅读(2590)  评论(0编辑  收藏  举报