webstorm eslint package path is not defined

有两种错误提示:

  1. TypeError: this.CliEngine is not a constructor
  2. packagePath is not defined

解决方法:
找到webstorm根目录,依次点开文件夹

安装目录\plugins\JavaScriptLanguage\languageService\eslint\bin\eslint-plugin.js

打开文件,找到下面的内容替换成:

1
2
3
4
// 注释下面这行
// this.cliEngine = require(packagePath + "lib/cli-engine").CLIEngine;
// 改为
this.cliEngine = require(this.basicPath + "lib/cli-engine").CLIEngine;

重启webstorm后,问题解决。


评论区