WebStorm 2018.1.4 + ESLint: TypeError: this.CliEngine is not a constructor
Andrew Henderson
My configuration is this.
WebStorm 2018.1.4; ESLint 6.4; Node 12.8; npm 6.10.2; Windows 8.1.
How do I eliminate the error in the thread title?
Here's a code sample.
import { GET_DAILY_SUCCESS, GET_HOURLY_SUCCESS, GET_MINUTE_SUCCESS
} from './types';
import { getDailyToUsd, getHourlyToUsd, getMinuteToUsd
} from '../api/cryptocompare';
import { setError } from './error';
export const getDaily = (fsym = 'BTC') => async dispatch => { try { const list = await getDailyToUsd(fsym); dispatch({ type: GET_DAILY_SUCCESS, currency: fsym, list }); } catch(err) { dispatch(setError(err.Message)); }
}; 7 Answers
WEB-38922 is fixed in 2019.1.3. The issue is with ESLint version 6.x. If upgrading Webstorm is not an option for you, you have to downgrade to ESLint version 5:
npm install --save-dev eslint@5Update: if you see similar error when working with ESLint 8, please make sure to upgrade to version 2021.2.2 where it's supported (see WEB-52236)
3In my Webstorm 2021.2 there is a slightly different error this.CliEngineCtor is not a constructor.
That is related to updating eslint to 8.0.1.
Solution: update WebStorm to the latest version 2021.2.2 or later
Here is another solution from Dmitry Babenko that will let you use ESLint 6.x with a fallback license of WebStorm:
1
- Wait for the
this.CliEngine is not a constructorballoon to appear and click "Details"- Follow the first link in the stack-trace to
eslint-plugin.jsfile- Find the following line at the top:
this.CliEngine = require(this.basicPath + "lib/cli-engine");
And replace it with the following one:this.CliEngine = require(this.basicPath).CLIEngine;- Restart IDEA
I'm using Webstorm2021.2.1 and I have figured out that eslint@8.0.0 is not compatible with it. This worked for me:
yarn add -D eslint@7.14.0 In additional to Dabrule answer:
For eslint v8 replace this line:
this.cliEngineCtor = requireInContext(eslintPackagePath + "lib/api", state.packageJsonPath).CLIEngine;to that:
this.cliEngineCtor = requireInContext(eslintPackagePath + "lib/cli-engine").CLIEngine;File location, for example, RubyMine (WebStorm should be similar):RubyMine-2021.1.3/plugins/JavaScriptLanguage/languageService/eslint/bin/eslint-plugin.js
upgrading to newer version will solve this error.
As you can see the issue was solved in 2019.1.3
WEB-38922 - Linting with ESLint v6 in 2019.1 fails with an error 'TypeError: this.cliEngine is not a constructor' :
1For mac users, you can open:/Applications/ and then as Johny Martin mentioned,
replace:
this.cliEngineCtor = requireInContext(eslintPackagePath + "lib/api", state.packageJsonPath).CLIEngine;with:
this.cliEngineCtor = requireInContext(eslintPackagePath + "lib/api", state.packageJsonPath).CLIEngine;then restart IDE, then it will work fine :)