vue2.0报错:Syntax Error: TypeError: eslint.CLIEngine is not a constructor

简介: vue2.0报错:Syntax Error: TypeError: eslint.CLIEngine is not a constructor

把vue.config.js文件的lintOnSave改为false

2345_image_file_copy_27.jpg

lintOnSave配置

Type: boolean | 'warning' | 'default' | 'error'
Default: true

设置是否在开发环境下每次保存代码时都启用 eslint验证

false:关闭每次保存都进行检测
true:开启每次保存都进行检测,效果与warning一样
‘warning’:开启每次保存都进行检测,lint 错误将显示到控制台命令行,而且编译并不会失败。
‘error’:开启每次保存都进行检测,lint 错误将显示到浏览器页面上,且编译失败。
‘default’:同’error’

用法:

module.exports = {
  publicPath: './', // 基本路径
  outputDir: 'dist', // 输出文件目录
  assetsDir: './assets',
  indexPath: 'index.html',
  filenameHashing: true, // 生成的静态资源在它们的文件名中包含了 hash 以便更好的控制缓存
  lintOnSave: false, // eslint-loader 是否在保存的时候检查
}

vue cli 3 lintOnSave 配置有时无效问题

一个使用vue cli 3.2创建的项目,创建时未开启 lintOnSave,后来希望开启并设置为 lintOnSave: ‘error’,但配置不生效。

解决方法1:新创建项目(此时vue cli 版本为 3.4)并开启 lintOnSave,然后删除其中所有文件,将旧有项目所有代码(包括node_modules)移动到新项目文件夹,发现lintOnSave报错页面提示有。

解决方法2:在 vue.config.js 中配置:

module.exports = {
    devServer: {
        overlay: {
            warnings: true,
            errors: true
        }
    },
    lintOnSave: 'error',
    chainWebpack: config => {
        config.module.rule('eslint').use('eslint-loader').loader('eslint-loader').tap(opt => {
            opt.emitWarning = opt.emitError = opt.failOnWarning = opt.failOnError = true;
            return opt;
        });
    }
};


目录
相关文章
|
17天前
|
JavaScript 应用服务中间件 nginx
vue项目中页面遇到404报错
vue项目中页面遇到404报错
|
3月前
vue3-admin-element-template配置正向代理报错
vue3-admin-element-template配置正向代理报错
34 0
|
4月前
|
JavaScript
vue3-在自定义hooks使用useRouter 报错问题
vue3-在自定义hooks使用useRouter 报错问题
108 0
|
1月前
vue3配置路由报错Catch all routes (“*“) must now be defined using a param with a custom regexp.
vue3配置路由报错Catch all routes (“*“) must now be defined using a param with a custom regexp.
43 0
|
4月前
|
JavaScript
鬼火起~为什么报错[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the
鬼火起~为什么报错[Vue warn]: Avoid mutating a prop directly since the value will be overwritten whenever the
|
13天前
|
JavaScript 算法 Linux
【vue报错】error:0308010C:digital envelope routines::unsupported
【vue报错】error:0308010C:digital envelope routines::unsupported
38 3
|
4月前
vue-3d-model.umd.js报错You may need an appropriate loader to handle this file type怎么办?
vue-3d-model.umd.js报错You may need an appropriate loader to handle this file type怎么办?
|
3月前
|
JavaScript
Vue报错 Invalid default value for prop “list“: Props with type Object/Array must use a factory
Vue报错 Invalid default value for prop “list“: Props with type Object/Array must use a factory
66 0
|
8天前
|
JavaScript
vue项目使用可选链操作符编译报错问题
vue项目使用可选链操作符编译报错问题
14 0
|
8天前
|
JavaScript
Vue项目启动报错处理
Vue项目启动报错处理
9 1