前端项目 启动报错?

node v16.15.0
npm 8.5.5
vue 2.x
npm run dev 报错
前端项目 启动报错?

 ERROR  ValidationError: Invalid options object. Dev Server has been initialized using an options object that do

es 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?, o

nListening?, open?, port?, proxy?, server?, setupExitSignals?, setupMiddlewares?, static?, watchFiles?, webSocke

tServer? }

看提示应该是这部分出了问题,但不知道是为啥,怎么改?

// webpack-dev-server 相关配置

devServer: {

host: '0.0.0.0',

port: port,

open: false,

proxy: {

// detail: https://cli.vuejs.org/config/#devserver-proxy

[process.env.VUE_APP_BASE_API]: {

target: `http://localhost:8989`,

changeOrigin: true,

pathRewrite: {

['^' + process.env.VUE_APP_BASE_API]: ''

}

}

},

disableHostCheck: true

},

在chatgpt中给出的方法将disableHostCheck换成

// 在这里添加额外的选项

allowedHosts: [

// 允许的 IP 或域名列表

'localhost',

'127.0.0.1'

]

也是报错


回答:

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?, o

nListening?, open?, port?, proxy?, server?, setupExitSignals?, setupMiddlewares?, static?, watchFiles?, webSocke

tServer? }

可用的配置字段里面不包括disableHostCheck,把disableHostCheck注释了再试试

以上是 前端项目 启动报错? 的全部内容, 来源链接: utcz.com/p/934223.html

回到顶部