webpack-dev-server 已使用与 API 模式不匹配的配置对象初始化
webpack-dev-server has been initialised using a configuration object that does not match the API schema
到目前为止,我所做的只是遵循 webpack 上的指南。
Windows10.
最初我使用的是节点 v6.11.1,但我现在已经升级到 8.5.0 以查看是否解决了问题;没有骰子。
我在某处读到 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?, stats?, reporter?, noInfo?, quiet?, serverSideRender?, index?, log?, warn? }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webpack-demo@1.0.0 start: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webpack-demo@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! 2017-09-14T13_46_40_808Z-debug.log
我的 webpack.config.js
文件如下所示:
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
entry: {
app: './src/index.js',
print: './src/print.js'
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
},
devServer: {
contentBase: './dist',
},
plugins: [
new CleanWebpackPlugin(['dist']),
new HtmlWebpackPlugin({
title: 'Output Management'
})
],
devtool: 'inline-source-map'
}
还有我的package.json
文件
{
"name": "webpack-demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "http-server",
"watch": "webpack --progress --watch",
"start": "webpack-dev-server --open",
"build": "webpack"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.24.1",
"clean-webpack-plugin": "^0.1.16",
"css-loader": "^0.28.7",
"file-loader": "^0.11.2",
"html-webpack-plugin": "^2.30.1",
"style-loader": "^0.18.2",
"webpack": "^3.5.6",
"webpack-dev-server": "^2.8.1"
},
"dependencies": {
"lodash": "^4.17.4"
}
}
这是直接的用户错误和疏忽。
在 "just following the guide" 之前,我正在处理其他事情,并使用 http-server
添加了一个 start
脚本。我不知道我看了多少次 package.json
并错过了它,但它就在那里。平淡无奇。
它要求我关闭控制台,因为它在后台 运行。一旦我关闭并重新打开控制台 window 和 运行 npm run start
webpack-dev-server
工作正常。
随时敲响耻辱钟。
到目前为止,我所做的只是遵循 webpack 上的指南。
Windows10.
最初我使用的是节点 v6.11.1,但我现在已经升级到 8.5.0 以查看是否解决了问题;没有骰子。
我在某处读到 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?, stats?, reporter?, noInfo?, quiet?, serverSideRender?, index?, log?, warn? }
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! webpack-demo@1.0.0 start: `webpack-dev-server`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the webpack-demo@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! 2017-09-14T13_46_40_808Z-debug.log
我的 webpack.config.js
文件如下所示:
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const CleanWebpackPlugin = require('clean-webpack-plugin');
module.exports = {
entry: {
app: './src/index.js',
print: './src/print.js'
},
output: {
filename: '[name].bundle.js',
path: path.resolve(__dirname, 'dist')
},
devServer: {
contentBase: './dist',
},
plugins: [
new CleanWebpackPlugin(['dist']),
new HtmlWebpackPlugin({
title: 'Output Management'
})
],
devtool: 'inline-source-map'
}
还有我的package.json
文件
{
"name": "webpack-demo",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"start": "http-server",
"watch": "webpack --progress --watch",
"start": "webpack-dev-server --open",
"build": "webpack"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-loader": "^7.1.2",
"babel-preset-es2015": "^6.24.1",
"clean-webpack-plugin": "^0.1.16",
"css-loader": "^0.28.7",
"file-loader": "^0.11.2",
"html-webpack-plugin": "^2.30.1",
"style-loader": "^0.18.2",
"webpack": "^3.5.6",
"webpack-dev-server": "^2.8.1"
},
"dependencies": {
"lodash": "^4.17.4"
}
}
这是直接的用户错误和疏忽。
在 "just following the guide" 之前,我正在处理其他事情,并使用 http-server
添加了一个 start
脚本。我不知道我看了多少次 package.json
并错过了它,但它就在那里。平淡无奇。
它要求我关闭控制台,因为它在后台 运行。一旦我关闭并重新打开控制台 window 和 运行 npm run start
webpack-dev-server
工作正常。
随时敲响耻辱钟。