webstrom打开项目时,js文件报错:ESLint: TypeError: this.cliEngine is not a constructor
今天用vue可视化创建了一个项目,然后用webstrom打开后,里面的js文件报了一个错误:ESLint: TypeError: this.cliEngine is not a constructor,这是因为本地项目的eslint版本和webstorm的eslint插件版本不一致导致的
解决方法如下:
点击details在控制台显示报错的位置
TypeError: this.cliEngine is not a constructor at ESLintPlugin.invokeESLint (/Applications/RubyMine.app/Contents/plugins/JavaScriptLanguage/languageService/eslint/bin/eslint-plugin.js:97:25) at ESLintPlugin.getErrors (/Applications/RubyMine.app/Contents/plugins/JavaScriptLanguage/languageService/eslint/bin/eslint-plugin.js:76:21) at ESLintPlugin.onMessage (/Applications/RubyMine.app/Contents/plugins/JavaScriptLanguage/languageService/eslint/bin/eslint-plugin.js:42:29) at Interface.<anonymous> (/Applications/RubyMine.app/Contents/plugins/JavaScriptLanguage/jsLanguageServicesImpl/js-language-service.js:105:39) at Interface.emit (events.js:189:13) at Interface._onLine (readline.js:290:10) at Interface._normalWrite (readline.js:433:12) at Socket.ondata (readline.js:149:10) at Socket.emit (events.js:189:13) at addChunk (_stream_readable.js:284:12) Process finished with exit code -1
修改这个文件的报错行:eslint-plugin.js
this.cliEngineCtor = requireInContext(eslintPackagePath + "lib/cli-engine", state.packageJsonPath).CLIEngine;
重启webstorm解决!
无论从事什么行业,只要做好两件事就够了,一个是你的专业、一个是你的人品,专业决定了你的存在,人品决定了你的人脉,剩下的就是坚持,用善良專業和真诚赢取更多的信任。