0%

解决TypeError: this.cliEngine is not a constructor

create-react-app工具创建了一个项目,使用IDEA打开项目,出现如下错误提示:

点击Detail查看:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
TypeError: this.cliEngine is not a constructor

TypeError: this.cliEngine is not a constructor
at ESLintPlugin.invokeESLint (/Applications/IntelliJ IDEA.app/Contents/plugins/JavaScriptLanguage/languageService/eslint/bin/eslint-plugin.js:97:25)
at ESLintPlugin.getErrors (/Applications/IntelliJ IDEA.app/Contents/plugins/JavaScriptLanguage/languageService/eslint/bin/eslint-plugin.js:76:21)
at ESLintPlugin.onMessage (/Applications/IntelliJ IDEA.app/Contents/plugins/JavaScriptLanguage/languageService/eslint/bin/eslint-plugin.js:42:29)
at Interface.<anonymous> (/Applications/IntelliJ IDEA.app/Contents/plugins/JavaScriptLanguage/jsLanguageServicesImpl/js-language-service.js:105:39)
at Interface.emit (events.js:198:13)
at Interface._onLine (readline.js:308:10)
at Interface._normalWrite (readline.js:451:12)
at Socket.ondata (readline.js:165:10)
at Socket.emit (events.js:198:13)
at addChunk (_stream_readable.js:288:12)
Process finished with exit code -1

编辑文件

把如下内容:

1
this.cliEngine = require(packagePath + "lib/cli-engine");

修改为:

1
this.cliEngine = require(packagePath + "lib/cli-engine").CLIEngine;

关闭项目,重新打开项目就可以了。