我正在研究区块链项目,每当我尝试运行“npm run dapp”时
我收到以下错误:
[webpack-cli] 选项对象无效。开发服务器已使用与 API 架构不匹配的选项对象进行初始化。
我正在使用 webpack:5.71.0 webpack-cli:4.9.2 webpack-dev-server 4.8.1
我的webpack.config.json文件如下
**const path = require('path')
const htmlWebpackPlugin = require('html-webpack-plugin')
require('babel-register')
module.exports = {
entry: ['@babel/polyfill', './src/app.js'],
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js'
},
module: {
rules: [
{
test: /\.js$/,
exclude: /node_modules/,
use: ['babel-loader']
}
]
},
plugins: [
new htmlWebpackPlugin({
template: './index.html'
})
],
mode: 'development',
devtool: 'inline-source-map',
devServer: {
static: {
directory: path.resolve(__dirname, 'public/'),
},
devMiddleware: {
publicPath: '/dist/'
},
port: 3000,
hot: "only"
}
}
**
I was expecting dapp application to run and give me webinterface. on http://localhost:8080
按照 webpack 从 v3 到 v4 的迁移指南后,这个特定问题得到了解决。 现在我的 webpack.config.dapp.js 文件部分名为“devServer”的更新如下: 开发服务器:{ 静态:path.join(__dirname,“dapp”), 端口:8000, devMiddleware: { stats: "最小", },