El Anonimo
El Anonimo

Reputation: 1870

WebStorm 2018.1.4 + ESLint: TypeError: this.CliEngine is not a constructor

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));
  }
};

Upvotes: 44

Views: 76071

Answers (7)

Leonid
Leonid

Reputation: 1

In additional to Dabrule and Johny Martin answer:

For eslint 8+ add .CLIEngine to this line:

this.CliEngine = require(this.basicPath + "lib/cli-engine").CLIEngine

Restart IDE (Webstorm 2018.1.2)

Upvotes: 0

Moshe Shpitz
Moshe Shpitz

Reputation: 31

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' : https://youtrack.jetbrains.com/issue/WEB-38922

Upvotes: 2

Johny Martin
Johny Martin

Reputation: 443

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

Upvotes: 25

lena
lena

Reputation: 93728

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@5

Update: 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)

Upvotes: 91

Alex Aymkin
Alex Aymkin

Reputation: 518

In 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

Upvotes: 35

Emad Baqeri
Emad Baqeri

Reputation: 2692

I'm using Webstorm2021.2.1 and I have figured out that [email protected] is not compatible with it. This worked for me:

yarn add -D [email protected]

Upvotes: 23

Dabrule
Dabrule

Reputation: 710

Here is another solution from Dmitry Babenko that will let you use ESLint 6.x with a fallback license of WebStorm:

  • Wait for the this.CliEngine is not a constructor balloon to appear and click "Details"
  • Follow the first link in the stack-trace to eslint-plugin.js file
  • 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

Upvotes: 25

Related Questions