简体   繁体   English

Webpack@5.66.0 Webpack 开发服务器配置:选项具有未知属性“统计”

[英]Webpack@5.66.0 Webpack dev server config: options has an unknown property 'stats'

Invalid options object.无效的选项 object。 Dev server has been initialized using an options object that does not match the API schema.已使用与 API 架构不匹配的选项 object 初始化开发服务器。

  • optionshas an unknown property 'stats'.选项有一个未知的属性“统计”。 These properties are valid: object { allowedHost?, 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?这些属性是有效的:object { allowedHost?, bonjour?, client?, compress?, devMiddleware?, headers?, historyApiFallback?, host?, hot?, http2?, https?, ipc?, onAfterSetupMiddleware?, magicH ?, onBeforeSetupMiddleware?, onListening?, open?, port?, proxy?, server?, setupExitSignals?, setupMiddlewares?, static?, watchFiles?, webSocketServer? } }

webpack.dev.server.js webpack.dev.server.js

module.exports = function getDevServerConfig(options) {
...
...
const devServer = {
...
...
disableHostCheck: true,
noInfo: false,
stats: {
assets: true,
color: true
}

}

}```

I was able to fix this issue by deleting node_modules and yarn.lock.我可以通过删除 node_modules 和 yarn.lock 来解决这个问题。 After that I ran yarn to rebuild node_modules and then yarn start worked without an issue.之后,我运行 yarn 来重建 node_modules,然后 yarn start 正常工作。

From the webpack-dev-server v4 migration guide:来自webpack-dev-server v4 迁移指南:

fs , index , mimeTypes , publicPath , serverSideRender , stats , and writeToDisk (related to webpack-dev-middleware ) were moved to devMiddleware option. fsindexmimeTypespublicPathserverSideRenderstatswriteToDisk (与webpack-dev-middleware相关)被移至devMiddleware选项。

https://github.com/webpack/webpack-dev-server/blob/master/migration-v4.md https://github.com/webpack/webpack-dev-server/blob/master/migration-v4.md

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 webpack 选项具有未知属性“hotOnly”。 无效的选项 object。 开发服务器已使用选项 object 初始化 - webpack options has an unknown property 'hotOnly'. Invalid options object. Dev Server has been initialized using an options object webpack-dev-server 返回“配置有一个未知的属性‘错误’” - webpack-dev-server return “configuration has an unknown property 'error'” Webpack配置有一个未知属性'preLoaders' - Webpack config has an unknown property 'preLoaders' webpack.config 有一个未知的属性“publicPath” - webpack.config has an unknown property 'publicPath' 将 webpack 4 更新到 webpack 5 get error options has an unknown property 'inline' - Update webpack 4 to webpack 5 get error options has an unknown property 'inline' 复制 webpack 插件错误选项具有未知属性“to” - copy webpack plugin error options has an unknown property 'to' Webpack.config.js:配置具有未知属性“默认” - Webpack.config.js: Configuration has an unknown property 'default' Webpack“开始”:“webpack-dev-server --config=config/webpack.dev.js”,不工作 - Webpack "start": "webpack-dev-server --config=config/webpack.dev.js", not working Webpack 开发服务器配置 - contentBase 不工作 - Webpack Dev Server Config - contentBase not working Webpack开发服务器开始使用production.webpack.config.js - Webpack dev server start using production.webpack.config.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM