Dav*_*ton 3 webpack webpack-dev-server
我安装了 webpack^3.0.0 和 webpack-dev-server^2.9.1 (在项目上和全局上)。在项目根目录中运行时webpack-dev-server,出现错误
Invalid configuration object. webpack-dev-server has been initialised
using a configuration object that does not match the API schema.
- configuration has an unknown property 'error'. These properties are
valid:
object { hot?, hotOnly?, lazy?, bonjour?, host?, allowedHosts?,
filename?, publicPath?, port?, socket?, watchOptions?, headers?,
clientLogLevel?, overlay?, progress?, key?, cert?, ca?, pfx?,
pfxPassphrase?, requestCert?, inline?, disableHostCheck?, public?,
https?, contentBase?, watchContentBase?, open?, useLocalIp?, openPage?,
features?, compress?, proxy?, historyApiFallback?, staticOptions?,
setup?, before?, after?, stats?, reporter?, noInfo?, quiet?,
serverSideRender?, index?, log?, warn? }
Run Code Online (Sandbox Code Playgroud)
projet 根目录下的 webpack.config.js 文件包含以下内容:
module.exports = {
entry: {
app: [
'./src/index.js'
]
},
module: {
loaders: [{
test: /\.jsx?$/,
exclude: /node_modules/,
loader: 'babel-loader'
}]
},
resolve: {
extensions: ['*', '.js', '.jsx']
},
output: {
path: __dirname + '/dist',
publicPath: '/',
filename: 'bundle.js'
},
devServer: {
inline: false,
contentBase: './dist'
}
};
Run Code Online (Sandbox Code Playgroud)
我已尝试遵循此问题中的建议,但无济于事。如何让 webpack 启动?
我还注意到,当我全局安装 webpack-dev-server^2.9.1 时,它拒绝承认其对等的 webpack^3.0.0,尽管它确实存在。这有关系吗?
该问题与问题末尾提到的全局安装有关。看来webpack-dev-server从项目根目录运行导致项目安装和全局安装都启动,因此它们存在相互的端口冲突。其中一个在检测到此冲突时抛出错误,另一个发现此错误,认为这是额外的配置输入。
使用 webpack-dev-server 的项目安装解决了该问题。
| 归档时间: |
|
| 查看次数: |
22771 次 |
| 最近记录: |