我想在 Symfony 5 中使用 Vue js,但在运行此命令“yarn encore dev-server”时遇到错误

问题描述

我在 Symfony 5 中使用 Vue.js 运行命令 yarn encore dev-server。我遇到了以下错误

PS C:\Apache24\htdocs\api_example> yarn encore dev-server

yarn run v1.22.5

$ C:\Apache24\htdocs\api_example\node_modules\.bin\encore dev-server

Running webpack-dev-server ...

 RECOMMEND  To create a smaller (and CSP-compliant) build,see https://symfony.com/doc/current/frontend/encore/vuejs.html#runtime-compiler-build

**[webpack-cli] Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
 - options.client has an unkNown property 'host'. These properties are valid:
   object { logging?,overlay?,progress?,webSocketTransport?,webSocketURL? }**


error Command Failed with exit code 2.

info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

enter image description here

解决方法

Webpack Dev Server 刚刚发布了一个新版本:v4.0.0-rc.0。它与 Webpack Encore 的(默认设置)不兼容。

您可以坚持使用 v4.0.0-beta.3 一段时间,直到 Webpack Encore 更新以支持新版本。

使用 yarn add webpack-dev-server@v4.0.0-beta.3 来使用这个确切的版本。

关注 this issue 以查看是否有任何进展,或者您是否想通过快速修复来使用新的 webpack-dev-server