开发服务器已使用与 API 架构不匹配的选项对象进行初始化
将 Angular 8 升级到 9 后,我收到以下错误,
An unhandled exception occurred: 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?,
See "/private/var/folders/fp/tmjy2_2j15s50f6qpyj6x6mm0000gr/T/ng-
xbMtW3/angular-errors.log" for further details.
从我读到的内容来看,我明白这与 webpack 有关 - 因为我没有 webpack 配置经验 - 我真的不知道从哪里开始。
这是我的 webpack.config.js
'use strict';
const path = require('path');
const SpritesmithPlugin = require('webpack-spritesmith');
const plugins = [
new SpritesmithPlugin({
src: {
cwd: path.resolve(__dirname, 'src/styles/icons'),
glob: '*.png'
},
target: {
image: path.resolve(__dirname, 'src/assets/images/sprite.png'),
css: path.resolve(__dirname, 'src/styles/_ui-sprite.scss')
},
apiOptions: {
cssImageRef: "assets\/images\/sprite.png",
generateSpriteName: function (sprite) {
return 'icon-' + path.basename(sprite, '.png');
}
}
})
];
module.exports = {
context: __dirname,
mode: 'development',
entry: {'doNotTouch': './doNotTouch.ts'},
output: {
path: __dirname,
filename: '[name].js'
},
plugins: plugins,
module: {
rules: []
}
};
I'm getting the following error after upgrading angular 8 to 9,
An unhandled exception occurred: 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?,
See "/private/var/folders/fp/tmjy2_2j15s50f6qpyj6x6mm0000gr/T/ng-
xbMtW3/angular-errors.log" for further details.
From what i've read i understood it's something to do with webpack - since i don't have experience with webpack configuration - i don't really know where to begin.
Here is my webpack.config.js
'use strict';
const path = require('path');
const SpritesmithPlugin = require('webpack-spritesmith');
const plugins = [
new SpritesmithPlugin({
src: {
cwd: path.resolve(__dirname, 'src/styles/icons'),
glob: '*.png'
},
target: {
image: path.resolve(__dirname, 'src/assets/images/sprite.png'),
css: path.resolve(__dirname, 'src/styles/_ui-sprite.scss')
},
apiOptions: {
cssImageRef: "assets\/images\/sprite.png",
generateSpriteName: function (sprite) {
return 'icon-' + path.basename(sprite, '.png');
}
}
})
];
module.exports = {
context: __dirname,
mode: 'development',
entry: {'doNotTouch': './doNotTouch.ts'},
output: {
path: __dirname,
filename: '[name].js'
},
plugins: plugins,
module: {
rules: []
}
};
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这很可能与您在不同文件夹中下载的模块的版本冲突有关。
删除所有节点模块和 Web 包并重新安装它们。
It most likely has to do with conflicting versions of a module you downloaded on different folders.
Delete all your node modules and web packages and reinstall them.