首页 > 解决方案 > 使用“npm start”运行 JHipster 生成的前端时出现“未知选项”错误

问题描述

每当我运行我的默认 JHipster 项目时(我只更改了后端的一些代码并进行了一些样式更改),我都会收到以下错误:

[webpack-cli] 错误:未知选项 '--inline' [webpack-cli] 运行 'webpack --help' 以查看可用的命令和选项

已经运行sudo npm i -S webpack@latest以确保我使用的是新的 webpack 版本。

如果我从命令中删除--inline,我会得到一个不同的错误:

1% setup initialize[webpack-cli] 无效的选项对象。开发服务器已使用与 API 架构不匹配的选项对象进行初始化。options 具有未知属性“watchOptions”。这些属性有效:object { allowedHosts?、bonjour?、client?、compress?、devMiddleware?、headers?、historyApiFallback?、host?、hot?、http2?、https?、ipc?、liveReload?、magicHtml?、onAfterSetupMiddleware ?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, setupExitSignals?, static?, watchFiles?, webSocketServer? }

这里有点困惑,因为我还没有设置项目,也有一段时间没有接触过 webpack - 感谢任何帮助并提前感谢!

标签: javascriptreactjswebpackjhipster

解决方案


It was simply a version dependency mismatch. For some reason, the Webpack Config was not defined for the same version as the as the one installed (v4 vs v5 respectively) - I simply assumed that the package json settings would prevent this from happening. I went through each error using the webpack docs and upgraded it according to the migration instructions.


推荐阅读