webpack-dev-server启动报错Invalid options object
使用yarn start启动项目时报错package.json相关依赖如下"webpack": "^4.43.0","webpack-cli": "^4.9.1","webpack-dev-server": "^4.5.0"报错信息如下:[webpack-cli] Invalid options object. Dev Server has been initialized using an op
·
使用yarn start启动项目时报错
package.json相关依赖如下
"webpack": "^4.43.0",
"webpack-cli": "^4.9.1",
"webpack-dev-server": "^4.5.0"
报错信息如下:
[webpack-cli] Invalid options object. Dev Server has been initialized using an options object that does not match the API schema.
- options has an unknown property 'contentBase'. 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?, static?, watchFiles?, webSocketServer? }
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
按提示,新版本的webpack配置文件webpack.config.json
格式调整了,不支持contentBase
devServer: {
// open: true,
contentBase: './',
port: 3009
},
修改成如下格式即可
{
static: {
directory: path.join(__dirname, './'),
},
compress: true,
port: 9000,
}
更多推荐
已为社区贡献3条内容
所有评论(0)