Vue3 webpack 报错:options has an unknown property 'hotOnly'. These properties are valid
0x00 问题描述
版本是vue3
,运行npm run serve
的时候报错:
INFO Starting development server...
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 'hotOnly'. 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 'hotOnly'. 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 (X:\xxx\xxx\admin\node_modules\webpack-dev-server\node_modules\schema-utils\dist\validate.js:115:11)
at new Server (X:\xxx\xxx\admin\node_modules\webpack-dev-server\lib\Server.js:231:5)
at serve (X:\xxx\xxx\admin\node_modules\@vue\cli-service\lib\commands\serve.js:185:20)
at processTicksAndRejections (internal/process/task_queues.js:97:5)
vue.config.js
的代码是这样的:
const { defineConfig } = require('@vue/cli-service')
module.exports = defineConfig({
transpileDependencies: true,
lintOnSave: false,
devServer: {
open: true,
host: 'localhost',
port: '8081',
https: false,
hotOnly: false,
proxy: {
'/api': {
target: 'http://192.168.99.100:8001',
changeOrigin: true,
pathRewrite: {
'^/user': ''
}
}
}
}
})
0x01 解决方案
hotOnly: false,
改成
hot: "only"
重启运行npm run serve
发现不报错了
0x02 参考文章
https://stackoverflow.com/questions/69102254/webpack-options-has-an-unknown-property-hotonly-invalid-options-object-dev-s