webstorm关于ESlint报错TypeError: this.cliEngine is not a constructor以及Module Error (from ./node_modules/eslint-loader/index.js):的解决方案
1.问题描述:
-
最近遇到一个不常遇到的问题:在
webstorm上面运行配置了ESlint的vue项目,项目刚跑起来是正常的,但是一开发就会报错,不论是添加、修改、删除代码,还是新增vue文件都会报下面两个错误: -
(1)
Failed to compile../src/components/test.vue
Module Error (from ./node_modules/eslint-loader/index.js): -
(2)
TypeError: this.cliEngine is not a constructor -
刚开始我以为是
eslint-loader加载插件出了问题,然后按照网上的方法重装ESlint,并且重新配置ESlint等等,都试了但是无济于事,后面我把目光集中在第二个问题上,把第二个问题解决后,第一个问题也没有了,项目恢复正常!(其实这个问题是webstorm本地ESlint版本过低导致的)下面分享一下我的解决方案:
2.解决方案:
-
1.找到
webstorm安装目录下ESlint的配置文件(可以参考下我的索引:C:\program files\WebStorm 2018.3.2\plugins\JavaScriptLanguage\languageService\eslint\bin\eslint-plugin.js)。 -
2.找到文件后,然后对
eslint-plugin.js进行重新配置(先对cliEngine进行关键词搜索,找到下面代码,copy配置后的代码即可): -
// 配置前 // this.cliEngine = require(packagePath + "lib/cli-engine") // 配置后 this.cliEngine = require(packagePath + "lib/cli-engine").CLIEngine;;
1695

被折叠的 条评论
为什么被折叠?



