Invalid options in vue.config.js: "devtool" is not allowed
时间: 2024-05-10 14:17:05 浏览: 18
这个错误通常出现在 `vue.config.js` 文件中使用了不被允许的选项,比如 `devtool`。这个问题的解决方法是查找并删除 `vue.config.js` 文件中不被允许的选项。
Vue CLI 4 以及更新版本中,`devtool` 选项已经被废弃,应该使用 `configureWebpack` 选项来配置 Webpack。如果你想配置 `devtool`,应该这样做:
```js
module.exports = {
configureWebpack: {
devtool: 'source-map'
}
}
```
如果你使用的是 Vue CLI 3 或者更早版本,你可以在 `vue.config.js` 文件中这样配置:
```js
module.exports = {
configureWebpack: {
devtool: 'source-map'
}
}
```
如果你已经删除了 `vue.config.js` 文件中的 `devtool` 选项,但是仍然出现这个错误,那么可能是因为其他选项也不被允许。你可以查看错误信息中提到的选项名字并进行相应的修改。
相关问题
Invalid options in vue.config.js: "devSever" is not allowed
The error message "Invalid options in vue.config.js: 'devSever' is not allowed" indicates that there is a typo in your Vue configuration file.
The correct option is "devServer" (with a capital S), not "devSever". So you need to update your configuration file to fix the typo.
Here's an example of a valid configuration file with the correct option:
```
module.exports = {
devServer: {
// Your dev server options here
}
}
```
Make sure to double-check your configuration file for any other typos or syntax errors as well.
Invalid options in vue.config.js: css.requireModuleExtension is not allowed
这个错误是因为在 Vue CLI 4 中,`css.requireModuleExtension` 被移除了,改为在 `vue.config.js` 中使用 `css.modules` 选项来启用 CSS 模块化。如果你想开启 CSS 模块化,可以在 `vue.config.js` 文件中添加以下代码:
```js
module.exports = {
css: {
requireModuleExtension: true,
modules: true
}
}
```
如果你不想使用 CSS 模块化,则可以将 `requireModuleExtension` 选项设置为 `false`,如下所示:
```js
module.exports = {
css: {
requireModuleExtension: false
}
}
```
在 Vue CLI 3 中,`css.requireModuleExtension` 仍然可用。如果你正在使用 Vue CLI 3,可以继续使用它。